From 01a743cd351d146e9b9ea7f7ca5b1c05e01da68e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 22 Feb 2015 00:28:23 -0500 Subject: Fix mistaken uses of memcpy() on overlapping memory. The source and destination arguments to memcpy() cannot be overlapping as this is undefined behavior. In these situations memmove() must be used instead, and OpenBSD actually throws an error if this is done. Thanks to ryan-sg for reporting this. This fixes #510. --- textscreen/txt_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'textscreen') diff --git a/textscreen/txt_io.c b/textscreen/txt_io.c index ed25503c..0c5e274f 100644 --- a/textscreen/txt_io.c +++ b/textscreen/txt_io.c @@ -39,8 +39,8 @@ static void NewLine(unsigned char *screendata) cur_y = TXT_SCREEN_H - 1; - memcpy(screendata, screendata + TXT_SCREEN_W * 2, - TXT_SCREEN_W * 2 * (TXT_SCREEN_H -1)); + memmove(screendata, screendata + TXT_SCREEN_W * 2, + TXT_SCREEN_W * 2 * (TXT_SCREEN_H -1)); // Clear the bottom line -- cgit v1.2.3