oleaut32: Fix null terminator in SysReAllocStringLen.
authorAlexander Kochetkov <al.kochet@gmail.com>
Wed, 14 Oct 2009 07:37:20 +0000 (11:37 +0400)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 14 Oct 2009 09:50:19 +0000 (11:50 +0200)
dlls/oleaut32/oleaut.c
dlls/oleaut32/tests/vartype.c

index 896d6d4da30936cdf7a8bf1c1c1b0a8385aa3b26..72b70e2369fd859c296bd3afe190f8e81ab630eb 100644 (file)
@@ -298,15 +298,12 @@ int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len)
       DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD));
       *old = (BSTR)(ptr+1);
       *ptr = newbytelen;
-      if (str) {
-        memmove(*old, str, newbytelen);
-        (*old)[len] = 0;
-      } else {
-       /* Subtle hidden feature: The old string data is still there
-        * when 'in' is NULL!
-        * Some Microsoft program needs it.
-        */
-      }
+      /* Subtle hidden feature: The old string data is still there
+       * when 'in' is NULL!
+       * Some Microsoft program needs it.
+       */
+      if (str) memmove(*old, str, newbytelen);
+      (*old)[len] = 0;
     } else {
       /*
        * Allocate the new string
index b50a673dec2dbc86676c0a6b55ca0fc665882330..87f290151a712de7724093eeb0e406bd77b6fcf5 100644 (file)
@@ -5422,7 +5422,7 @@ static void test_SysReAllocStringLen(void)
       if (str)
       {
         ok (str == oldstr, "Expected reuse of the old string memory\n");
-        todo_wine ok (str[STRING_SIZE] == 0,
+        ok (str[STRING_SIZE] == 0,
             "Expected null terminator, got 0x%04X\n", str[STRING_SIZE]);
         SysFreeString(str);
       }