Initialize the output buffer parameters to 0 in RegQueryValue*

functions. This is important specially when there's no data to return.
This commit is contained in:
Noomen Hamza 1999-04-22 09:05:19 +00:00 committed by Alexandre Julliard
parent f4b6e82b84
commit 7a0c2e6294
1 changed files with 12 additions and 0 deletions

View File

@ -2504,6 +2504,9 @@ DWORD WINAPI RegQueryValueExW( HKEY hkey, LPWSTR lpValueName,
if ((lpbData && ! lpcbData) || lpdwReserved)
return ERROR_INVALID_PARAMETER;
if (lpbData && lpcbData)
memset(lpbData,0,*lpcbData);
/* An empty name string is equivalent to NULL */
if (lpValueName && !*lpValueName)
lpValueName = NULL;
@ -2573,6 +2576,9 @@ DWORD WINAPI RegQueryValueW( HKEY hkey, LPCWSTR lpszSubKey, LPWSTR lpszData,
TRACE(reg,"(%x,%s,%p,%ld)\n",hkey,debugstr_w(lpszSubKey),lpszData,
lpcbData?*lpcbData:0);
if (lpszData && lpcbData)
memset(lpszData,0,*lpcbData);
/* Only open subkey, if we really do descend */
if (lpszSubKey && *lpszSubKey) {
ret = RegOpenKeyW( hkey, lpszSubKey, &xhkey );
@ -2615,6 +2621,9 @@ DWORD WINAPI RegQueryValueExA( HKEY hkey, LPSTR lpszValueName,
{ return ERROR_INVALID_PARAMETER;
}
if (lpbData && lpcbData)
memset(lpbData,0,*lpcbData);
lpszValueNameW = lpszValueName ? strdupA2W(lpszValueName) : NULL;
/* get just the type first */
@ -2685,6 +2694,9 @@ DWORD WINAPI RegQueryValueA( HKEY hkey, LPCSTR lpszSubKey, LPSTR lpszData,
TRACE(reg,"(%x,%s,%p,%ld)\n",hkey,debugstr_a(lpszSubKey),lpszData,
lpcbData?*lpcbData:0);
if (lpszData && lpcbData)
memset(lpszData,0,*lpcbData);
if (lpszSubKey && *lpszSubKey) {
ret = RegOpenKey16( hkey, lpszSubKey, &xhkey );
if( ret != ERROR_SUCCESS )