Alexander Kochetkov : oleaut32/tests: Checking null terminator in return value of SysReAllocStringLen.

Alexandre Julliard julliard at winehq.org
Wed Oct 14 09:02:00 CDT 2009


Module: wine
Branch: master
Commit: b6da072551cf6eb88d1500df5127802face30a18
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b6da072551cf6eb88d1500df5127802face30a18

Author: Alexander Kochetkov <al.kochet at gmail.com>
Date:   Wed Oct 14 11:27:10 2009 +0400

oleaut32/tests: Checking null terminator in return value of SysReAllocStringLen.

---

 dlls/oleaut32/tests/vartype.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index b7528c4..b50a673 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -5397,6 +5397,37 @@ static void test_SysReAllocStringLen(void)
 
     SysFreeString(str);
   }
+
+  /* Windows always returns null terminated strings */
+  str = SysAllocStringLen(szTest, 4);
+  ok (str != NULL, "Expected non-NULL\n");
+  if (str)
+  {
+    const int CHUNK_SIZE = 64;
+    const int STRING_SIZE = 24;
+    int changed;
+    changed = SysReAllocStringLen(&str, NULL, CHUNK_SIZE);
+    ok (changed == 1, "Expected 1, got %d\n", changed);
+    ok (str != NULL, "Expected non-NULL\n");
+    if (str)
+    {
+      BSTR oldstr = str;
+
+      /* Filling string */
+      memset (str, 0xAB, CHUNK_SIZE * sizeof (OLECHAR));
+      /* Checking null terminator */
+      changed = SysReAllocStringLen(&str, NULL, STRING_SIZE);
+      ok (changed == 1, "Expected 1, got %d\n", changed);
+      ok (str != NULL, "Expected non-NULL\n");
+      if (str)
+      {
+        ok (str == oldstr, "Expected reuse of the old string memory\n");
+        todo_wine ok (str[STRING_SIZE] == 0,
+            "Expected null terminator, got 0x%04X\n", str[STRING_SIZE]);
+        SysFreeString(str);
+      }
+    }
+  }
 }
 
 static void test_BstrCopy(void)




More information about the wine-cvs mailing list