Rob Shearman : rpcrt4: Don' t crash with a NULL binding handle in RpcBindingFree.
Alexandre Julliard
julliard at winehq.org
Mon Nov 16 11:44:02 CST 2009
Module: wine
Branch: master
Commit: cdc10a8d3b262f5010c0f78ce4053c363ff151a3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cdc10a8d3b262f5010c0f78ce4053c363ff151a3
Author: Rob Shearman <robertshearman at gmail.com>
Date: Mon Nov 16 14:40:26 2009 +0000
rpcrt4: Don't crash with a NULL binding handle in RpcBindingFree.
---
dlls/rpcrt4/rpc_binding.c | 7 +++++--
dlls/rpcrt4/tests/rpc.c | 12 ++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c
index b264b9a..212e201 100644
--- a/dlls/rpcrt4/rpc_binding.c
+++ b/dlls/rpcrt4/rpc_binding.c
@@ -785,8 +785,11 @@ RPC_STATUS WINAPI RpcBindingFree( RPC_BINDING_HANDLE* Binding )
{
RPC_STATUS status;
TRACE("(%p) = %p\n", Binding, *Binding);
- status = RPCRT4_ReleaseBinding(*Binding);
- if (status == RPC_S_OK) *Binding = 0;
+ if (*Binding)
+ status = RPCRT4_ReleaseBinding(*Binding);
+ else
+ status = RPC_S_INVALID_BINDING;
+ if (status == RPC_S_OK) *Binding = NULL;
return status;
}
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index 01d7392..0f742b2 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -800,6 +800,17 @@ static void test_UuidCreate(void)
}
}
+static void test_RpcBindingFree(void)
+{
+ RPC_BINDING_HANDLE binding = NULL;
+ RPC_STATUS status;
+
+ status = RpcBindingFree(&binding);
+ ok(status == RPC_S_INVALID_BINDING,
+ "RpcBindingFree should have retured RPC_S_INVALID_BINDING instead of %d\n",
+ status);
+}
+
START_TEST( rpc )
{
UuidConversionAndComparison();
@@ -811,4 +822,5 @@ START_TEST( rpc )
test_I_RpcExceptionFilter();
test_RpcStringBindingFromBinding();
test_UuidCreate();
+ test_RpcBindingFree();
}
More information about the wine-cvs
mailing list