aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/unix/ttsl_drv.c
diff options
context:
space:
mode:
authorSteve Vinoski <[email protected]>2013-04-21 18:36:02 -0400
committerSteve Vinoski <[email protected]>2013-04-21 20:18:06 -0400
commit4907e049b4d409d2b6220b140e38360bb837720b (patch)
tree1b4ef662260d3e2ebdbd43d0891fcf080b63168d /erts/emulator/drivers/unix/ttsl_drv.c
parent7e9ae3007fd3c44a05a746628983faff401dfd0c (diff)
downloadotp-4907e049b4d409d2b6220b140e38360bb837720b.tar.gz
otp-4907e049b4d409d2b6220b140e38360bb837720b.tar.bz2
otp-4907e049b4d409d2b6220b140e38360bb837720b.zip
fix valgrind error in erts/emulator/drivers/unix/ttsl_drv.c
Running some valgrind memory checking showed the error below: ==18040== Thread 6: ==18040== Source and destination overlap in memcpy(0xf3f3f04, 0xf3f3f08, 52) ==18040== at 0x4C2CFA0: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==18040== by 0x5CF527: del_chars (ttsl_drv.c:845) ==18040== by 0x5CED5E: ttysl_from_erlang (ttsl_drv.c:658) ==18040== by 0x4982E3: erts_write_to_port (io.c:1235) ==18040== by 0x49A2BD: erts_port_command (io.c:2223) ==18040== by 0x48C054: do_send (bif.c:1962) ==18040== by 0x48CB6E: erl_send (bif.c:2162) ==18040== by 0x566599: process_main (beam_emu.c:1665) ==18040== by 0x4B1A95: sched_thread_func (erl_process.c:4834) ==18040== by 0x6075E2: thr_wrapper (ethread.c:106) ==18040== by 0x5560E99: start_thread (pthread_create.c:308) This occurred on Linux using R15B01 while the shell was emitting a prompt, but the same problem is still present in R16B. Change the memcpy on line 845 of ttsl_drv.c to memmove as valgrind suggests. After the change, verify with valgrind that the error no longer occurs.
Diffstat (limited to 'erts/emulator/drivers/unix/ttsl_drv.c')
-rw-r--r--erts/emulator/drivers/unix/ttsl_drv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/erts/emulator/drivers/unix/ttsl_drv.c b/erts/emulator/drivers/unix/ttsl_drv.c
index 8912d148a5..8b24eb98c0 100644
--- a/erts/emulator/drivers/unix/ttsl_drv.c
+++ b/erts/emulator/drivers/unix/ttsl_drv.c
@@ -842,7 +842,7 @@ static int del_chars(int n)
move_cursor(lpos, lpos-l); /* Move back */
/* Fix up buffer and buffer pointers. */
if (r > 0)
- memcpy(lbuf + pos, lbuf + lpos, r * sizeof(Uint32));
+ memmove(lbuf + pos, lbuf + lpos, r * sizeof(Uint32));
lpos -= l;
llen -= l;
/* Write out characters after, blank the tail and jump back to lpos. */