Alistair Leslie-Hughes : dpnet: Correct GetComponentByName to return the correct buffer size.
Alexandre Julliard
julliard at winehq.org
Thu Oct 13 14:34:01 CDT 2016
Module: wine
Branch: master
Commit: 7c609f07b4e1e9a5f0c0ef38329c461e1a9b3ea8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7c609f07b4e1e9a5f0c0ef38329c461e1a9b3ea8
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Thu Oct 13 10:07:08 2016 +0000
dpnet: Correct GetComponentByName to return the correct buffer size.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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);
More information about the wine-cvs
mailing list