Fixed some bogus error detection for RegEnumValue[AW] and
RegQueryValueEx[AW].

diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 6b8b581..5d102e8 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -64,7 +64,7 @@
         if (*count < len) ret = ERROR_MORE_DATA;
         else memcpy( data, src, len );
     }
-    *count = len;
+    if (count) *count = len;
     return ret;
 }
 
@@ -87,7 +87,7 @@
         if (*count < len) ret = ERROR_MORE_DATA;
         else memcpy( data, src, len );
     }
-    *count = len;
+    if (count) *count = len;
     return ret;
 }
 
@@ -728,7 +728,7 @@
     TRACE("(0x%x,%s,%p,%p,%p,%p=%ld)\n",
           hkey, debugstr_w(name), reserved, type, data, count, count ? *count : 0 );
 
-    if (!count || reserved) return ERROR_INVALID_PARAMETER;
+    if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
 
     req->hkey = hkey;
     if ((ret = copy_nameW( req->name, name )) != ERROR_SUCCESS) return ret;
@@ -756,7 +756,7 @@
     TRACE("(0x%x,%s,%p,%p,%p,%p=%ld)\n",
           hkey, debugstr_a(name), reserved, type, data, count, count ? *count : 0 );
 
-    if (!count || reserved) return ERROR_INVALID_PARAMETER;
+    if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
 
     req->hkey = hkey;
     if ((ret = copy_nameAtoW( req->name, name )) != ERROR_SUCCESS) return ret;
@@ -847,7 +847,7 @@
           hkey, index, value, val_count, reserved, type, data, count );
 
     /* NT only checks count, not val_count */
-    if (!count || reserved) return ERROR_INVALID_PARAMETER;
+    if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
 
     req->hkey = hkey;
     req->index = index;
@@ -876,7 +876,7 @@
           hkey, index, value, val_count, reserved, type, data, count );
 
     /* NT only checks count, not val_count */
-    if (!count || reserved) return ERROR_INVALID_PARAMETER;
+    if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
 
     req->hkey = hkey;
     req->index = index;