Module: wine Branch: master Commit: 5a6cb3818d997facda046d2eed331f3c7790d913 URL: https://source.winehq.org/git/wine.git/?a=commit;h=5a6cb3818d997facda046d2ee...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Fri Sep 7 13:56:13 2018 +0300
opcservices: Fix argument handling in CreatePackageRootUri().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/opcservices/factory.c | 3 +++ dlls/opcservices/tests/opcservices.c | 21 +++++++++++++++++---- dlls/opcservices/uri.c | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/opcservices/factory.c b/dlls/opcservices/factory.c index 2ecd5ad..9036141 100644 --- a/dlls/opcservices/factory.c +++ b/dlls/opcservices/factory.c @@ -312,6 +312,9 @@ static HRESULT WINAPI opc_factory_CreatePackageRootUri(IOpcFactory *iface, IOpcU { TRACE("iface %p, uri %p.\n", iface, uri);
+ if (!uri) + return E_POINTER; + return opc_root_uri_create(uri); }
diff --git a/dlls/opcservices/tests/opcservices.c b/dlls/opcservices/tests/opcservices.c index 63932fe..84a8c12 100644 --- a/dlls/opcservices/tests/opcservices.c +++ b/dlls/opcservices/tests/opcservices.c @@ -41,16 +41,18 @@ static void test_package(void) static const WCHAR typeW[] = {'t','y','p','e','/','s','u','b','t','y','p','e',0}; static const WCHAR targetW[] = {'t','a','r','g','e','t',0}; static const WCHAR uriW[] = {'/','u','r','i',0}; + static const WCHAR rootW[] = {'/',0}; IOpcRelationshipSet *relset, *relset2; IOpcPartSet *partset, *partset2; IOpcRelationship *rel; IOpcPartUri *part_uri; IOpcFactory *factory; IOpcPackage *package; - IOpcUri *source_uri; IUri *target_uri; IOpcPart *part; + IOpcUri *uri; HRESULT hr; + BSTR str; BOOL ret;
factory = create_factory(); @@ -93,11 +95,11 @@ static void test_package(void) hr = IOpcRelationshipSet_CreateRelationship(relset, NULL, typeW, target_uri, OPC_URI_TARGET_MODE_INTERNAL, &rel); ok(SUCCEEDED(hr), "Failed to create relationship, hr %#x.\n", hr);
- hr = IOpcRelationship_GetSourceUri(rel, &source_uri); + hr = IOpcRelationship_GetSourceUri(rel, &uri); ok(SUCCEEDED(hr), "Failed to get source uri, hr %#x.\n", hr); - ok(source_uri == (IOpcUri *)part_uri, "Unexpected source uri.\n"); + ok(uri == (IOpcUri *)part_uri, "Unexpected source uri.\n");
- IOpcUri_Release(source_uri); + IOpcUri_Release(uri);
IOpcRelationship_Release(rel); IUri_Release(target_uri); @@ -126,6 +128,17 @@ todo_wine {
IOpcPackage_Release(package);
+ /* Root uri */ + hr = IOpcFactory_CreatePackageRootUri(factory, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + hr = IOpcFactory_CreatePackageRootUri(factory, &uri); + ok(SUCCEEDED(hr), "Failed to create root uri, hr %#x.\n", hr); + hr = IOpcUri_GetRawUri(uri, &str); + ok(SUCCEEDED(hr), "Failed to get raw uri, hr %#x.\n", hr); + ok(!lstrcmpW(str, rootW), "Unexpected uri %s.\n", wine_dbgstr_w(str)); + SysFreeString(str); + IOpcUri_Release(uri); + IOpcFactory_Release(factory); }
diff --git a/dlls/opcservices/uri.c b/dlls/opcservices/uri.c index 0c5afa9..e461eba 100644 --- a/dlls/opcservices/uri.c +++ b/dlls/opcservices/uri.c @@ -552,6 +552,8 @@ HRESULT opc_root_uri_create(IOpcUri **out) HRESULT hr; IUri *uri;
+ *out = NULL; + if (!(obj = heap_alloc_zero(sizeof(*obj)))) return E_OUTOFMEMORY;