Commit 5b723235 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32: Check source pointer in StringFromGUID2.

parent 2d2edc9a
......@@ -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] );
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment