From: Jactry Zeng Subject: [PATCH v2] netprofm: Initialize ret value in IEnumNetworkConnections_Next(). Message-Id: <20210120052617.106593-1-jzeng@codeweavers.com> Date: Wed, 20 Jan 2021 13:26:17 +0800 Signed-off-by: Jactry Zeng --- v2: Simplify test. --- dlls/netprofm/list.c | 2 ++ dlls/netprofm/tests/list.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/netprofm/list.c b/dlls/netprofm/list.c index f9b9e2ea312..fa94916dd9b 100644 --- a/dlls/netprofm/list.c +++ b/dlls/netprofm/list.c @@ -1001,6 +1001,8 @@ static HRESULT WINAPI connections_enum_Next( TRACE( "%p, %u %p %p\n", iter, count, ret, fetched ); + if (!ret) return E_POINTER; + *ret = NULL; if (fetched) *fetched = 0; if (!count) return S_OK; diff --git a/dlls/netprofm/tests/list.c b/dlls/netprofm/tests/list.c index ff7755162cc..56052ceb512 100644 --- a/dlls/netprofm/tests/list.c +++ b/dlls/netprofm/tests/list.c @@ -229,7 +229,7 @@ static void test_INetworkListManager( void ) INetworkConnection *conn; DWORD cookie; HRESULT hr; - ULONG ref1, ref2; + ULONG ref1, ref2, fetched; IID iid; hr = CoCreateInstance( &CLSID_NetworkListManager, NULL, CLSCTX_INPROC_SERVER, @@ -355,11 +355,22 @@ static void test_INetworkListManager( void ) ok( hr == S_OK, "got %08x\n", hr ); if (conn_iter) { + fetched = 256; + hr = IEnumNetworkConnections_Next( conn_iter, 1, NULL, &fetched ); + ok( hr == E_POINTER, "got hr %#x.\n", hr ); + ok( fetched == 256, "got wrong feteched: %d.\n", fetched ); + + hr = IEnumNetworkConnections_Next( conn_iter, 0, NULL, &fetched ); + ok( hr == E_POINTER, "got hr %#x.\n", hr ); + ok( fetched == 256, "got wrong feteched: %d.\n", fetched ); + while ((hr = IEnumNetworkConnections_Next( conn_iter, 1, &conn, NULL )) == S_OK) { test_INetworkConnection( conn ); INetworkConnection_Release( conn ); + conn = (void *)0xdeadbeef; } + ok( !conn, "got wrong pointer: %p.\n", conn ); IEnumNetworkConnections_Release( conn_iter ); } -- 2.29.2