diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c index c65d576..e2f1cba 100644 --- a/dlls/shlwapi/string.c +++ b/dlls/shlwapi/string.c @@ -477,7 +477,8 @@ LPWSTR WINAPI StrCatW(LPWSTR lpszStr, LPCWSTR lpszSrc) { TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSrc)); - strcatW(lpszStr, lpszSrc); + if (lpszStr && lpszSrc) + strcatW(lpszStr, lpszSrc); return lpszStr; } @@ -497,7 +498,8 @@ LPWSTR WINAPI StrCpyW(LPWSTR lpszStr, LPCWSTR lpszSrc) { TRACE("(%p,%s)\n", lpszStr, debugstr_w(lpszSrc)); - strcpyW(lpszStr, lpszSrc); + if (lpszStr && lpszSrc) + strcpyW(lpszStr, lpszSrc); return lpszStr; } diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c index c918bcc..b23bf0b 100644 --- a/dlls/shlwapi/tests/string.c +++ b/dlls/shlwapi/tests/string.c @@ -407,16 +407,25 @@ 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++; } + + lpRes = StrCpyW(szBuff, NULL); + ok(lpRes == szBuff, "Wrong return value: got %p expected %p\n", lpRes, szBuff); + + lpRes = StrCpyW(NULL, szSrc); + ok(lpRes == NULL, "Wrong return value: got %p expected NULL\n", lpRes); + + lpRes = StrCpyW(NULL, NULL); + ok(lpRes == NULL, "Wrong return value: got %p expected NULL\n", lpRes); } static void test_StrChrNW(void)