oleaut32: Fix SysReAllocStringLen implementation.
This commit is contained in:
parent
17bec80f71
commit
7e3fd4e3c6
|
@ -294,6 +294,7 @@ int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len)
|
|||
return 0;
|
||||
|
||||
if (*old!=NULL) {
|
||||
BSTR old_copy = *old;
|
||||
DWORD newbytelen = len*sizeof(WCHAR);
|
||||
DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD));
|
||||
*old = (BSTR)(ptr+1);
|
||||
|
@ -302,7 +303,7 @@ int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len)
|
|||
* when 'in' is NULL!
|
||||
* Some Microsoft program needs it.
|
||||
*/
|
||||
if (str) memmove(*old, str, newbytelen);
|
||||
if (str && old_copy!=str) memmove(*old, str, newbytelen);
|
||||
(*old)[len] = 0;
|
||||
} else {
|
||||
/*
|
||||
|
|
|
@ -5440,6 +5440,20 @@ static void test_SysReAllocStringLen(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Some Windows applications use the same pointer for pbstr and psz */
|
||||
str = SysAllocStringLen(szTest, 4);
|
||||
ok(str != NULL, "Expected non-NULL\n");
|
||||
if(str)
|
||||
{
|
||||
int changed;
|
||||
|
||||
changed = SysReAllocStringLen(&str, str, 1000000);
|
||||
ok(SysStringLen(str)==1000000, "Incorrect string length\n");
|
||||
ok(!memcmp(szTest, str, 4*sizeof(WCHAR)), "Incorrect string returned\n");
|
||||
|
||||
SysFreeString(str);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_BstrCopy(void)
|
||||
|
|
Loading…
Reference in New Issue