Set (when registry loaded) data to "\0" and length to 2 in empty

string value case, in place of setting data to NULL and length to 0,
and this is without initializing output buffer parameter of
RegQueryValue*.
This commit is contained in:
Noomen Hamza 1999-04-24 11:49:26 +00:00 committed by Alexandre Julliard
parent ad1e06ef76
commit 9adef53dee
1 changed files with 8 additions and 12 deletions

View File

@ -947,6 +947,14 @@ static void _find_or_add_value( LPKEYSTRUCT lpkey, LPWSTR name, DWORD type,
if (val->lastmodified<lastmodified) {
val->lastmodified=lastmodified;
val->type = type;
if ((type == REG_SZ || type == REG_EXPAND_SZ) && !data){
data=xmalloc(sizeof(WCHAR));
memset(data,0,sizeof(WCHAR));
len =sizeof(WCHAR);
}
val->len = len;
if (val->data)
free(val->data);
@ -2504,9 +2512,6 @@ 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;
@ -2576,9 +2581,6 @@ 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 );
@ -2621,9 +2623,6 @@ 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 */
@ -2694,9 +2693,6 @@ 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 )