https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2a783979ff660f5267c3c…
commit 2a783979ff660f5267c3c2020b8ff06bf9ab0341
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Mon Dec 19 09:18:22 2022 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Mon Dec 19 09:18:48 2022 +0100
[RPCRT4] RpcStringFreeA/W must set the pointer to NULL
Add a matching wine test.
This change will be sent upstream.
---
dll/win32/rpcrt4/rpcrt4_main.c | 2 ++
modules/rostests/winetests/rpcrt4/rpc.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/dll/win32/rpcrt4/rpcrt4_main.c b/dll/win32/rpcrt4/rpcrt4_main.c
index 67a3dbe595f..7cc8d0b06b2 100644
--- a/dll/win32/rpcrt4/rpcrt4_main.c
+++ b/dll/win32/rpcrt4/rpcrt4_main.c
@@ -158,6 +158,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID
lpvReserved)
RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR* String)
{
HeapFree( GetProcessHeap(), 0, *String);
+ if (String) *String = NULL;
return RPC_S_OK;
}
@@ -174,6 +175,7 @@ RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR* String)
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR* String)
{
HeapFree( GetProcessHeap(), 0, *String);
+ if (String) *String = NULL;
return RPC_S_OK;
}
diff --git a/modules/rostests/winetests/rpcrt4/rpc.c
b/modules/rostests/winetests/rpcrt4/rpc.c
index d3a3aee6c8c..dcf7a2d9608 100644
--- a/modules/rostests/winetests/rpcrt4/rpc.c
+++ b/modules/rostests/winetests/rpcrt4/rpc.c
@@ -854,6 +854,22 @@ static void test_RpcBindingFree(void)
status);
}
+static void test_RpcStringFree(void)
+{
+ RPC_WSTR string = NULL;
+
+ string = HeapAlloc(GetProcessHeap(), 0, 10*sizeof(WCHAR));
+ if (string == NULL)
+ {
+ skip("Failed to allocate a string!\n");
+ return;
+ }
+
+ RpcStringFreeW(&string);
+
+ ok(string == NULL, "String is %p expected NULL!\n", string);
+}
+
static void test_RpcServerInqDefaultPrincName(void)
{
RPC_STATUS ret;
@@ -1204,6 +1220,7 @@ START_TEST( rpc )
test_UuidCreate();
test_UuidCreateSequential();
test_RpcBindingFree();
+ test_RpcStringFree();
test_RpcServerInqDefaultPrincName();
test_RpcServerRegisterAuthInfo();