Hans Leidekker : shlwapi: Fix parameter check for UrlUnescapeA.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Feb 16 05:34:10 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 7c9918338a21a70b1eac3fdd14fb7a55470a211a
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=7c9918338a21a70b1eac3fdd14fb7a55470a211a

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Thu Feb 16 12:08:48 2006 +0100

shlwapi: Fix parameter check for UrlUnescapeA.
NULL pszUnescaped is okay if URL_UNESCAPE_INPLACE is set.
Add a corresponding test for UrlUnescape{A,W}.

---

 dlls/shlwapi/tests/path.c |    8 ++++++++
 dlls/shlwapi/url.c        |    2 +-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c
index 6800da2..aa0a519 100644
--- a/dlls/shlwapi/tests/path.c
+++ b/dlls/shlwapi/tests/path.c
@@ -585,6 +585,9 @@ static void test_UrlUnescape(void)
     WCHAR *urlW, *expected_urlW; 
     DWORD dwEscaped;
     size_t i;
+    static char inplace[] = "file:///C:/Program%20Files";
+    static WCHAR inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/',
+                               'P','r','o','g','r','a','m','%','2','0','F','i','l','e','s',0};
 
     for(i=0; i<sizeof(TEST_URL_UNESCAPE)/sizeof(TEST_URL_UNESCAPE[0]); i++) { 
         dwEscaped=INTERNET_MAX_URL_LENGTH;
@@ -601,6 +604,11 @@ static void test_UrlUnescape(void)
         FreeWideString(expected_urlW);
     }
 
+    dwEscaped = sizeof(inplace);
+    ok(UrlUnescapeA(inplace, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeA failed unexpectedly\n");
+
+    dwEscaped = sizeof(inplaceW);
+    ok(UrlUnescapeW(inplaceW, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
 }
 
 static void test_PathSearchAndQualify(void)
diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c
index 7211420..9747eef 100644
--- a/dlls/shlwapi/url.c
+++ b/dlls/shlwapi/url.c
@@ -1117,7 +1117,7 @@ HRESULT WINAPI UrlUnescapeA(
     TRACE("(%s, %p, %p, 0x%08lx)\n", debugstr_a(pszUrl), pszUnescaped,
 	  pcchUnescaped, dwFlags);
 
-    if(!pszUrl || !pszUnescaped || !pcchUnescaped)
+    if(!pszUrl || (!pszUnescaped && !(dwFlags & URL_UNESCAPE_INPLACE)) || !pcchUnescaped)
 	return E_INVALIDARG;
 
     if(dwFlags & URL_UNESCAPE_INPLACE)




More information about the wine-cvs mailing list