summaryrefslogtreecommitdiff
path: root/textscreen
diff options
context:
space:
mode:
authorSimon Howard2015-02-22 00:28:23 -0500
committerSimon Howard2015-02-22 00:28:23 -0500
commit01a743cd351d146e9b9ea7f7ca5b1c05e01da68e (patch)
tree122dbb74806badb164f6bd780334780bbc7b0595 /textscreen
parentb39121c6a682eb8ae5efd29a875bd7c098185f04 (diff)
downloadchocolate-doom-01a743cd351d146e9b9ea7f7ca5b1c05e01da68e.tar.gz
chocolate-doom-01a743cd351d146e9b9ea7f7ca5b1c05e01da68e.tar.bz2
chocolate-doom-01a743cd351d146e9b9ea7f7ca5b1c05e01da68e.zip
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.
Diffstat (limited to 'textscreen')
-rw-r--r--textscreen/txt_io.c4
1 files changed, 2 insertions, 2 deletions
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