[PATCH 09/10] Check source pointer in StringFromGUID2

Nikolay Sivov bunglehead at gmail.com
Sun Oct 4 14:32:18 CDT 2009


---
 dlls/ole32/compobj.c       |    2 +-
 dlls/ole32/tests/compobj.c |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index b2013cf..c8c4808 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -1621,7 +1621,7 @@ INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
                                      '%','0','4','X','-','%','0','2','X','%','0','2','X','-',
                                      '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',
                                      '%','0','2','X','%','0','2','X','}',0 };
-    if (cmax < CHARS_IN_GUID) return 0;
+    if (!id || cmax < CHARS_IN_GUID) return 0;
     sprintfW( str, formatW, id->Data1, id->Data2, id->Data3,
               id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
               id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index 1cfe86b..442e7b0 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -203,6 +203,13 @@ static void test_StringFromGUID2(void)
 {
   WCHAR str[50];
   int len;
+
+  /* invalid pointer */
+  SetLastError(0xdeadbeef);
+  len = StringFromGUID2(NULL,str,50);
+  ok(len == 0, "len: %d (expected 0)\n", len);
+  ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %x\n", GetLastError());
+
   /* Test corner cases for buffer size */
   len = StringFromGUID2(&CLSID_StdFont,str,50);
   ok(len == 39, "len: %d (expected 39)\n", len);
-- 
1.5.6.5


--=-dCVn+4PmvV4AGOjlN3EN--




More information about the wine-patches mailing list