Module: wine Branch: master Commit: 5b723235d8302469f86f585a44fe336d5df6bdf6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5b723235d8302469f86f585a44...
Author: Nikolay Sivov bunglehead@gmail.com Date: Mon Oct 5 23:06:22 2009 +0400
ole32: Check source pointer in StringFromGUID2.
---
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);