[PATCH] shlwapi: Fix pointer and size in AssocQueryStringA

Detlef Riekenberg wine.dev at web.de
Thu Oct 16 17:55:52 CDT 2008


---
 dlls/shlwapi/assoc.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/shlwapi/assoc.c b/dlls/shlwapi/assoc.c
index 9e4b036..a145cbc 100644
--- a/dlls/shlwapi/assoc.c
+++ b/dlls/shlwapi/assoc.c
@@ -300,9 +300,14 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
     WCHAR szReturnW[MAX_PATH], *lpszReturnW = szReturnW;
     DWORD dwLenOut = *pcchOut;
 
-    if (dwLenOut >= MAX_PATH)
+    if (dwLenOut >= MAX_PATH) {
       lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
                                       (dwLenOut + 1) * sizeof(WCHAR));
+    }
+    else
+    {
+      dwLenOut = sizeof(szReturnW) / sizeof(szReturnW[0]);
+    }
 
     if (!lpszReturnW)
       hRet = E_OUTOFMEMORY;
@@ -311,8 +316,10 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
       hRet = AssocQueryStringW(cfFlags, str, lpszAssocW, lpszExtraW,
                                lpszReturnW, &dwLenOut);
 
-      if (SUCCEEDED(hRet))
-        WideCharToMultiByte(CP_ACP,0,szReturnW,-1,pszOut,dwLenOut,0,0);
+      if (SUCCEEDED(hRet)) {
+        dwLenOut = WideCharToMultiByte(CP_ACP, 0, lpszReturnW, -1,
+                                       pszOut, *pcchOut, NULL, NULL);
+      }
       *pcchOut = dwLenOut;
 
       if (lpszReturnW != szReturnW)
-- 
1.5.4.3


--=-xm4tTxM3t05hRsta3VVg--




More information about the wine-patches mailing list