PATCH: sysreallocstringlen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Undocumented feature, the stringbase reallocated by SysReAllocStringLen
is from the old BSTR, when 'in' is NULL.

This 'feature' is requird by a MS VB5 app installer.

Ciao, Marcus

Changelog:
	Do not free the old string in SysReAllocStringLen, reuse
	the old string memory (if 'in' is NULL).

Index: dlls/oleaut32/oleaut.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/oleaut.c,v
retrieving revision 1.27
diff -u -u -r1.27 oleaut.c
--- dlls/oleaut32/oleaut.c	5 Jan 2003 20:32:30 -0000	1.27
+++ dlls/oleaut32/oleaut.c	26 Jan 2003 21:57:32 -0000
@@ -206,16 +206,26 @@
     if (old==NULL)
       return 0;
 
-    /*
-     * Make sure we free the old string.
-     */
-    if (*old!=NULL)
-      SysFreeString(*old);
-
-    /*
-     * Allocate the new string
-     */
-    *old = SysAllocStringLen(in, len);
+    if (*old!=NULL) {
+      DWORD newbytelen = len*sizeof(WCHAR);
+      DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD));
+      *old = (BSTR)(ptr+1);
+      *ptr = newbytelen;
+      if (in) {
+        memcpy(*old, in, newbytelen);
+        (*old)[newbytelen] = 0;
+      } else {
+	/* Subtle hidden feature: The old string data is still there
+	 * when 'in' is NULL! 
+	 * Some Microsoft program needs it.
+	 */
+      }
+    } else {
+      /*
+       * Allocate the new string
+       */
+      *old = SysAllocStringLen(in, len);
+    }
 
     return 1;
 }


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux