From 5bd3875c8ff6acff762b6b251fdaccc49e1b0b65 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Feb 2004 14:59:05 +0000 Subject: [PATCH] Small changee takes care of the following valgrind messages: ==32343== Source and destination overlap in memcpy(0x4192492c, 0x4192492c, 20) ==32343== at 0x40020351: memcpy (mac_replace_strmem.c:95) ==32343== by 0x80BC95B: scramble (common/gamecode/economy.c:132) ==32343== by 0x80BCA71: expandorders (common/gamecode/economy.c:169) ==32343== by 0x80BCB75: expandrecruit (common/gamecode/economy.c:199) ==32343== ==32343== Source and destination overlap in memcpy(0x443f3de0, 0x443f3de0, 20) ==32343== at 0x40020351: memcpy (mac_replace_strmem.c:95) ==32343== by 0x80BC95B: scramble (common/gamecode/economy.c:132) ==32343== by 0x80BCA71: expandorders (common/gamecode/economy.c:169) ==32343== by 0x80C31A4: expandtax (common/gamecode/economy.c:3108) ==32343== ==32343== Source and destination overlap in memcpy(0x425a5b4c, 0x425a5b4c, 20) ==32343== at 0x40020351: memcpy (mac_replace_strmem.c:95) ==32343== by 0x80BC95B: scramble (common/gamecode/economy.c:132) ==32343== by 0x80BCA71: expandorders (common/gamecode/economy.c:169) ==32343== by 0x80C09C3: expandbuying (common/gamecode/economy.c:1949) ==32343== ==32343== Source and destination overlap in memcpy(0x425a78e0, 0x425a78e0, 20) ==32343== at 0x40020351: memcpy (mac_replace_strmem.c:95) ==32343== by 0x80BC95B: scramble (common/gamecode/economy.c:132) ==32343== by 0x80BCA71: expandorders (common/gamecode/economy.c:169) ==32343== by 0x80C10A3: expandselling (common/gamecode/economy.c:2180) ==32343== --- src/common/gamecode/economy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index f7c899ceb..3d77f244a 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -128,6 +128,7 @@ scramble(void *data, int n, size_t width) assert(width<=sizeof(temp)); for (j=0;j!=n;++j) { int k = rand() % n; + if (k==j) continue; memcpy(temp, (char*)data+j*width, width); memcpy((char*)data+j*width, (char*)data+k*width, width); memcpy((char*)data+k*width, temp, width);