mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
[SHLWAPI][SHLWAPI_APITEST] Fix NULL behavior of StrDupA/W (#6720)
Fix wrong behavior of shlwapi!StrDupA and shlwapi!StrDupW functions. JIRA issue: CORE-19495 Return NULL when lpszStr == NULL.
This commit is contained in:
parent
0cfc9aba05
commit
ff531eaade
4 changed files with 57 additions and 0 deletions
|
@ -1068,6 +1068,10 @@ LPSTR WINAPI StrDupA(LPCSTR lpszStr)
|
|||
|
||||
TRACE("(%s)\n",debugstr_a(lpszStr));
|
||||
|
||||
#ifdef __REACTOS__
|
||||
if (!lpszStr)
|
||||
return NULL;
|
||||
#endif
|
||||
iLen = lpszStr ? strlen(lpszStr) + 1 : 1;
|
||||
lpszRet = LocalAlloc(LMEM_FIXED, iLen);
|
||||
|
||||
|
@ -1093,6 +1097,10 @@ LPWSTR WINAPI StrDupW(LPCWSTR lpszStr)
|
|||
|
||||
TRACE("(%s)\n",debugstr_w(lpszStr));
|
||||
|
||||
#ifdef __REACTOS__
|
||||
if (!lpszStr)
|
||||
return NULL;
|
||||
#endif
|
||||
iLen = (lpszStr ? strlenW(lpszStr) + 1 : 1) * sizeof(WCHAR);
|
||||
lpszRet = LocalAlloc(LMEM_FIXED, iLen);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ list(APPEND SOURCE
|
|||
SHLoadIndirectString.c
|
||||
SHLoadRegUIString.c
|
||||
SHPropertyBag.cpp
|
||||
StrDup.c
|
||||
StrFormatByteSizeW.c
|
||||
testdata.rc
|
||||
testlist.c)
|
||||
|
|
46
modules/rostests/apitests/shlwapi/StrDup.c
Normal file
46
modules/rostests/apitests/shlwapi/StrDup.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* PROJECT: ReactOS api tests
|
||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||
* PURPOSE: Tests for StrDupA/W
|
||||
* COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||
*/
|
||||
|
||||
#include <apitest.h>
|
||||
#include <shlwapi.h>
|
||||
#include <versionhelpers.h>
|
||||
|
||||
static void TEST_StrDupA(void)
|
||||
{
|
||||
LPSTR ptrA;
|
||||
|
||||
ptrA = StrDupA(NULL);
|
||||
|
||||
if (IsWindowsXPOrGreater())
|
||||
ok_ptr(ptrA, NULL);
|
||||
else
|
||||
ok(ptrA && !*ptrA, "ptrA: '%s'\n", wine_dbgstr_a(ptrA));
|
||||
|
||||
if (ptrA)
|
||||
LocalFree(ptrA);
|
||||
}
|
||||
|
||||
static void TEST_StrDupW(void)
|
||||
{
|
||||
LPWSTR ptrW;
|
||||
|
||||
ptrW = StrDupW(NULL);
|
||||
|
||||
if (IsWindowsXPOrGreater())
|
||||
ok_ptr(ptrW, NULL);
|
||||
else
|
||||
ok(ptrW && !*ptrW, "ptrW: '%s'\n", wine_dbgstr_w(ptrW));
|
||||
|
||||
if (ptrW)
|
||||
LocalFree(ptrW);
|
||||
}
|
||||
|
||||
START_TEST(StrDup)
|
||||
{
|
||||
TEST_StrDupA();
|
||||
TEST_StrDupW();
|
||||
}
|
|
@ -13,6 +13,7 @@ extern void func_SHGetRestriction(void);
|
|||
extern void func_SHLoadIndirectString(void);
|
||||
extern void func_SHLoadRegUIString(void);
|
||||
extern void func_SHPropertyBag(void);
|
||||
extern void func_StrDup(void);
|
||||
extern void func_StrFormatByteSizeW(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
|
@ -29,6 +30,7 @@ const struct test winetest_testlist[] =
|
|||
{ "SHLoadIndirectString", func_SHLoadIndirectString },
|
||||
{ "SHLoadRegUIString", func_SHLoadRegUIString },
|
||||
{ "SHPropertyBag", func_SHPropertyBag },
|
||||
{ "StrDup", func_StrDup },
|
||||
{ "StrFormatByteSizeW", func_StrFormatByteSizeW },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue