[PATCH] dpnet: Correct GetComponentByName to return the correct buffer size
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Thu Oct 13 05:07:08 CDT 2016
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
dlls/dpnet/address.c | 4 ++--
dlls/dpnet/tests/address.c | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/dpnet/address.c b/dlls/dpnet/address.c
index d87d4e7..6305fe7 100644
--- a/dlls/dpnet/address.c
+++ b/dlls/dpnet/address.c
@@ -377,9 +377,9 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Add
struct component *entry;
DWORD i;
- TRACE("(%p)->(%p %p %p %p)\n", This, pwszName, pvBuffer, pdwBufferSize, pdwDataType);
+ TRACE("(%p)->(%s %p %p %p)\n", This, debugstr_w(pwszName), pvBuffer, pdwBufferSize, pdwDataType);
- if(!pwszName || !pdwBufferSize || !pdwDataType || (!pvBuffer && pdwBufferSize))
+ if(!pwszName || !pdwBufferSize || !pdwDataType || (!pvBuffer && *pdwBufferSize))
return E_POINTER;
for(i=0; i < This->comp_count; i++)
diff --git a/dlls/dpnet/tests/address.c b/dlls/dpnet/tests/address.c
index cb226f9..dd0ef23 100644
--- a/dlls/dpnet/tests/address.c
+++ b/dlls/dpnet/tests/address.c
@@ -123,6 +123,15 @@ static void address_addcomponents(void)
hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, &localhost, sizeof(localhost)+2, DPNA_DATATYPE_STRING);
ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr);
+ size = 0;
+ hr = IDirectPlay8Address_GetComponentByName(localaddr, DPNA_KEY_HOSTNAME, NULL, &size, &type);
+ ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr);
+ ok(size == sizeof(localhost), "Invalid string length: %d\n", size);
+
+ size = 1;
+ hr = IDirectPlay8Address_GetComponentByName(localaddr, DPNA_KEY_HOSTNAME, NULL, &size, &type);
+ ok(hr == E_POINTER, "got 0x%08x\n", hr);
+
size = sizeof(buffer);
hr = IDirectPlay8Address_GetComponentByName(localaddr, DPNA_KEY_HOSTNAME, buffer, &size, &type);
ok(hr == S_OK, "got 0x%08x\n", hr);
--
2.9.3
More information about the wine-patches
mailing list