Zero out return string in GetMenuStringA/W.

This commit is contained in:
Uwe Bonnes 2005-03-30 10:24:07 +00:00 committed by Alexandre Julliard
parent 9a99a39e0b
commit af305c7462
1 changed files with 2 additions and 2 deletions

View File

@ -3277,10 +3277,10 @@ INT WINAPI GetMenuStringA(
MENUITEM *item; MENUITEM *item;
TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags ); TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags );
if (str && nMaxSiz) str[0] = '\0';
if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0; if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
if (!IS_STRING_ITEM(item->fType)) return 0; if (!IS_STRING_ITEM(item->fType)) return 0;
if (!str || !nMaxSiz) return strlenW(item->text); if (!str || !nMaxSiz) return strlenW(item->text);
str[0] = '\0';
if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL )) if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL ))
str[nMaxSiz-1] = 0; str[nMaxSiz-1] = 0;
TRACE("returning '%s'\n", str ); TRACE("returning '%s'\n", str );
@ -3297,10 +3297,10 @@ INT WINAPI GetMenuStringW( HMENU hMenu, UINT wItemID,
MENUITEM *item; MENUITEM *item;
TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags ); TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags );
if (str && nMaxSiz) str[0] = '\0';
if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0; if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
if (!IS_STRING_ITEM(item->fType)) return 0; if (!IS_STRING_ITEM(item->fType)) return 0;
if (!str || !nMaxSiz) return strlenW(item->text); if (!str || !nMaxSiz) return strlenW(item->text);
str[0] = '\0';
lstrcpynW( str, item->text, nMaxSiz ); lstrcpynW( str, item->text, nMaxSiz );
return strlenW(str); return strlenW(str);
} }