[PATCH 1/2] oleaut32/tests: Test return value of SysReAllocStringLen for the null terminator.

Alexander Kochetkov al.kochet at gmail.com
Tue Oct 13 11:27:05 CDT 2009


This test works fine under windows 98, XP and under wine.
And allways check for the null terminator.

see bug 20334.
-------------- next part --------------
From c9d3b978eb3d9ce70a3baf06176ecc70098b2257 Mon Sep 17 00:00:00 2001
From: Alexander Kochetkov <al.kochet at gmail.com>
Date: Tue, 13 Oct 2009 20:07:18 +0400
Subject: [PATCH 1/2] oleaut32/tests: Test return value of SysReAllocStringLen for the null terminator.
To: wine-patches <wine-patches at winehq.org>
Reply-To: wine-devel <wine-devel at winehq.org>

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

diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index 0321013..6813a49 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -5383,6 +5383,34 @@ static void test_SysReAllocStringLen(void)
 
     SysFreeString(str);
   }
+  
+  /* Windows always return 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;
+    SysReAllocStringLen(&str, NULL, CHUNK_SIZE);
+    ok (str != NULL, "Expected non-NULL\n");
+    if (str)
+    {
+      BSTR oldstr = str;
+
+      /* Fill the string */
+      memset (str, 0xAB, CHUNK_SIZE * sizeof (OLECHAR));
+      /* Test for null terminator */
+      SysReAllocStringLen(&str, NULL, STRING_SIZE);
+      ok (str != NULL, "Expected non-NULL\n");
+      if (str)
+      {
+        ok (str == oldstr, "Expected reuse of the old string memory\n");
+        ok (str[STRING_SIZE] == 0, 
+            "Expected null terminator, got 0x%04X\n", str[STRING_SIZE]);
+        SysFreeString(str);
+      }
+    }
+  }
 }
 
 static void test_BstrCopy(void)
-- 
1.6.0.4


More information about the wine-patches mailing list