SHQueryValueExW and Valgrind

Francois Gouget fgouget at codeweavers.com
Wed Nov 19 17:31:24 CST 2003


SHQueryValueExW would use the output parameters of RegQueryValueExW even 
if the registry value did not exist. In particular it used dwType which 
is not initialized in case of a failure thus causing a Valgrind warning.


Changelog:

  * dlls/shlwapi/reg.c

    Francois Gouget <fgouget at codeweavers.com>
    Don't use the data returned by RegQueryValueExW if it fails (found 
by Valgrind).
    A spelling fix.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/shlwapi/reg.c
===================================================================
RCS file: /home/cvs/wine/dlls/shlwapi/reg.c,v
retrieving revision 1.43
diff -u -r1.43 reg.c
--- dlls/shlwapi/reg.c	15 Oct 2003 21:02:53 -0000	1.43
+++ dlls/shlwapi/reg.c	19 Nov 2003 21:31:49 -0000
@@ -1240,6 +1240,8 @@
   if (pcbData) dwUnExpDataLen = *pcbData;
 
   dwRet = RegQueryValueExW(hKey, lpszValue, lpReserved, &dwType, pvData, &dwUnExpDataLen);
+  if (dwRet!=ERROR_SUCCESS && dwRet!=ERROR_MORE_DATA)
+      return dwRet;
 
   if (pcbData && (dwType == REG_EXPAND_SZ))
   {
@@ -1248,7 +1250,7 @@
     /* Expand type REG_EXPAND_SZ into REG_SZ */
     LPWSTR szData;
 
-    /* If the caller didn't supply a buffer or the buffer is to small we have
+    /* If the caller didn't supply a buffer or the buffer is too small we have
      * to allocate our own
      */
     if ((!pvData) || (dwRet == ERROR_MORE_DATA) )


More information about the wine-patches mailing list