shlwapi: Add NULL checks to StrCpyW and StrCatW.
This commit is contained in:
parent
d4d39736ce
commit
f6524a9f77
|
@ -477,6 +477,7 @@ LPWSTR WINAPI StrCatW(LPWSTR lpszStr, LPCWSTR lpszSrc)
|
|||
{
|
||||
TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSrc));
|
||||
|
||||
if (lpszStr && lpszSrc)
|
||||
strcatW(lpszStr, lpszSrc);
|
||||
return lpszStr;
|
||||
}
|
||||
|
@ -497,6 +498,7 @@ LPWSTR WINAPI StrCpyW(LPWSTR lpszStr, LPCWSTR lpszSrc)
|
|||
{
|
||||
TRACE("(%p,%s)\n", lpszStr, debugstr_w(lpszSrc));
|
||||
|
||||
if (lpszStr && lpszSrc)
|
||||
strcpyW(lpszStr, lpszSrc);
|
||||
return lpszStr;
|
||||
}
|
||||
|
|
|
@ -407,16 +407,28 @@ static void test_StrCpyW(void)
|
|||
WCHAR szSrc[256];
|
||||
WCHAR szBuff[256];
|
||||
const StrFormatSizeResult* result = StrFormatSize_results;
|
||||
|
||||
LPWSTR lpRes;
|
||||
|
||||
while(result->value)
|
||||
{
|
||||
MultiByteToWideChar(0,0,result->byte_size_64,-1,szSrc,sizeof(szSrc)/sizeof(WCHAR));
|
||||
|
||||
StrCpyW(szBuff, szSrc);
|
||||
ok(!StrCmpW(szSrc, szBuff), "Copied string %s wrong\n", result->byte_size_64);
|
||||
lpRes = StrCpyW(szBuff, szSrc);
|
||||
ok(!StrCmpW(szSrc, szBuff) && lpRes == szBuff, "Copied string %s wrong\n", result->byte_size_64);
|
||||
result++;
|
||||
}
|
||||
|
||||
/* this test crashes on win2k SP4 */
|
||||
/*lpRes = StrCpyW(szBuff, NULL);*/
|
||||
/*ok(lpRes == szBuff, "Wrong return value: got %p expected %p\n", lpRes, szBuff);*/
|
||||
|
||||
/* this test crashes on win2k SP4 */
|
||||
/*lpRes = StrCpyW(NULL, szSrc);*/
|
||||
/*ok(lpRes == NULL, "Wrong return value: got %p expected NULL\n", lpRes);*/
|
||||
|
||||
/* this test crashes on win2k SP4 */
|
||||
/*lpRes = StrCpyW(NULL, NULL);*/
|
||||
/*ok(lpRes == NULL, "Wrong return value: got %p expected NULL\n", lpRes);*/
|
||||
}
|
||||
|
||||
static void test_StrChrNW(void)
|
||||
|
|
Loading…
Reference in New Issue