From af305c7462e58638947377301bbe6da9dffe95cf Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Wed, 30 Mar 2005 10:24:07 +0000 Subject: [PATCH] Zero out return string in GetMenuStringA/W. --- dlls/user/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/user/menu.c b/dlls/user/menu.c index c471246e689..48c490926ce 100644 --- a/dlls/user/menu.c +++ b/dlls/user/menu.c @@ -3277,10 +3277,10 @@ INT WINAPI GetMenuStringA( MENUITEM *item; 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 (!IS_STRING_ITEM(item->fType)) return 0; if (!str || !nMaxSiz) return strlenW(item->text); - str[0] = '\0'; if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL )) str[nMaxSiz-1] = 0; TRACE("returning '%s'\n", str ); @@ -3297,10 +3297,10 @@ INT WINAPI GetMenuStringW( HMENU hMenu, UINT wItemID, MENUITEM *item; 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 (!IS_STRING_ITEM(item->fType)) return 0; if (!str || !nMaxSiz) return strlenW(item->text); - str[0] = '\0'; lstrcpynW( str, item->text, nMaxSiz ); return strlenW(str); } -- 2.11.4.GIT