msvcrt tests: fix memory leak (found by Smatch).

Lionel Debroux lionel_debroux at yahoo.fr
Fri Oct 26 04:15:26 CDT 2007


---
 dlls/msvcrt/tests/string.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 6dabc61..6ffcd28 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -388,7 +388,7 @@ static void test_strdup(void)
 
 START_TEST(string)
 {
-    void *mem;
+    char mem[100];
     static const char xilstring[]="c:/xilinx";
     int nLen;
 
@@ -401,13 +401,11 @@ START_TEST(string)
 
     /* MSVCRT memcpy behaves like memmove for overlapping moves,
        MFC42 CString::Insert seems to rely on that behaviour */
-    mem = malloc(100);
-    ok(mem != NULL, "memory not allocated for size 0\n");
-    strcpy((char*)mem,xilstring);
+    strcpy(mem,xilstring);
     nLen=strlen(xilstring);
-    pmemcpy((char*)mem+5, mem,nLen+1);
-    ok(pmemcmp((char*)mem+5,xilstring, nLen) == 0, 
-       "Got result %s\n",(char*)mem+5);
+    pmemcpy(mem+5, mem,nLen+1);
+    ok(pmemcmp(mem+5,xilstring, nLen) == 0, 
+       "Got result %s\n",mem+5);
 
     /* Test _swab function */
     test_swab();
-- 
1.5.3.2


--0-2120060252-1193390553=:81864--



More information about the wine-patches mailing list