[PATCH] VerQueryValueA/W allow blank and NULl strings

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Nov 18 04:47:21 CST 2008


---
 dlls/version/info.c       |    6 ++++++
 dlls/version/tests/info.c |   14 ++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/dlls/version/info.c b/dlls/version/info.c
index 51e25b3..6a79603 100644
--- a/dlls/version/info.c
+++ b/dlls/version/info.c
@@ -777,6 +777,9 @@ BOOL WINAPI VerQueryValueA( LPCVOID pBlock, LPCSTR lpSubBlock,
      if (!pBlock)
         return FALSE;
 
+    if (lpSubBlock == NULL || strlen(lpSubBlock) == 0)
+        lpSubBlock = rootA;
+
     if ( !VersionInfoIs16( info ) )
     {
         BOOL ret;
@@ -832,6 +835,9 @@ BOOL WINAPI VerQueryValueW( LPCVOID pBlock, LPCWSTR lpSubBlock,
     if (!pBlock)
         return FALSE;
 
+    if (lpSubBlock == NULL || strlenW(lpSubBlock) == 0)
+        lpSubBlock = rootW;
+
     if ( VersionInfoIs16( info ) )
     {
         BOOL ret;
diff --git a/dlls/version/tests/info.c b/dlls/version/tests/info.c
index a64d911..1eca21a 100644
--- a/dlls/version/tests/info.c
+++ b/dlls/version/tests/info.c
@@ -248,6 +248,13 @@ static void test_info(void)
     if (!boolret)
         goto cleanup;
 
+    boolret = VerQueryValueA( pVersionInfo, NULL, (LPVOID *)&pFixedVersionInfo, &uiLength );
+    ok (boolret || GetLastError() == NO_ERROR /* Win98 */, 
+       "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
+
+    boolret = VerQueryValueA( pVersionInfo, "", (LPVOID *)&pFixedVersionInfo, &uiLength );
+    ok (boolret, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
+
     boolret = VerQueryValueA( pVersionInfo, backslash, (LPVOID *)&pFixedVersionInfo, &uiLength );
     ok (boolret, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
     if (!boolret)
@@ -286,6 +293,7 @@ static void test_32bit_win(void)
     WCHAR mypathW[MAX_PATH];
     char rootA[] = "\\";
     WCHAR rootW[] = { '\\', 0 };
+    WCHAR emptyW[] = { 0 };
     char varfileinfoA[] = "\\VarFileInfo\\Translation";
     WCHAR varfileinfoW[]    = { '\\','V','a','r','F','i','l','e','I','n','f','o',
                                 '\\','T','r','a','n','s','l','a','t','i','o','n', 0 };
@@ -392,6 +400,12 @@ static void test_32bit_win(void)
 
     if (is_unicode_enabled)
     { 
+        retW = VerQueryValueW( pVersionInfoW, NULL, (LPVOID *)&pBufW, &uiLengthW );
+        ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
+
+        retW = VerQueryValueW( pVersionInfoW, emptyW, (LPVOID *)&pBufW, &uiLengthW );
+        ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
+
         retW = VerQueryValueW( pVersionInfoW, rootW, (LPVOID *)&pBufW, &uiLengthW );
         ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
         ok ( uiLengthA == sizeof(VS_FIXEDFILEINFO), "Size (%d) doesn't match the size of the VS_FIXEDFILEINFO struct\n", uiLengthA);
-- 
1.5.4.3


--------------030404040901080409070805--



More information about the wine-patches mailing list