From c79be42057ea20751c2b15c9ced2f4498798e093 Mon Sep 17 00:00:00 2001 From: Thomas Mullaly Date: Wed, 12 May 2010 22:35:59 -0400 Subject: [PATCH] urlmon: CreateUri should return E_INVALIDARG for NULL args. --- dlls/urlmon/tests/uri.c | 19 ++++++++++++++++++- dlls/urlmon/uri.c | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c index 13d69fcf5f..a9786065bc 100644 --- a/dlls/urlmon/tests/uri.c +++ b/dlls/urlmon/tests/uri.c @@ -20,7 +20,9 @@ /* * IUri testing framework goals: - * - Test invalid flags + * - Test invalid args + * - invalid flags + * - invalid args (IUri, uri string) * - Test parsing for components when no canonicalization occurs * - Test parsing for components when canonicalization occurs. * - More tests... @@ -75,6 +77,18 @@ static void test_CreateUri_InvalidFlags(void) { } } +static void test_CreateUri_InvalidArgs(void) { + HRESULT hr; + IUri *uri = (void*) 0xdeadbeef; + + hr = pCreateUri(http_urlW, 0, 0, NULL); + ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG); + + hr = pCreateUri(NULL, 0, 0, &uri); + ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG); + ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri); +} + START_TEST(uri) { HMODULE hurlmon; @@ -88,4 +102,7 @@ START_TEST(uri) { trace("test CreateUri invalid flags...\n"); test_CreateUri_InvalidFlags(); + + trace("test CreateUri invalid args...\n"); + test_CreateUri_InvalidArgs(); } diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c index 668aa9b710..5b72fa53e8 100644 --- a/dlls/urlmon/uri.c +++ b/dlls/urlmon/uri.c @@ -296,6 +296,14 @@ HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IU TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved, ppURI); + if(!ppURI) + return E_INVALIDARG; + + if(!pwzURI) { + *ppURI = NULL; + return E_INVALIDARG; + } + ret = heap_alloc(sizeof(Uri)); if(!ret) return E_OUTOFMEMORY;