Alexander Kochetkov : oleaut32: Fix null terminator in SysReAllocStringLen.
Alexandre Julliard
julliard at winehq.org
Wed Oct 14 09:02:00 CDT 2009
Module: wine
Branch: master
Commit: ae4de9d6956a18b2e8bff0cfd2a3122e30e05fe6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ae4de9d6956a18b2e8bff0cfd2a3122e30e05fe6
Author: Alexander Kochetkov <al.kochet at gmail.com>
Date: Wed Oct 14 11:37:20 2009 +0400
oleaut32: Fix null terminator in SysReAllocStringLen.
---
dlls/oleaut32/oleaut.c | 15 ++++++---------
dlls/oleaut32/tests/vartype.c | 2 +-
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/dlls/oleaut32/oleaut.c b/dlls/oleaut32/oleaut.c
index 896d6d4..72b70e2 100644
--- a/dlls/oleaut32/oleaut.c
+++ b/dlls/oleaut32/oleaut.c
@@ -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
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index b50a673..87f2901 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -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);
}
More information about the wine-cvs
mailing list