Protect SetMenu from rogue menu handle.
GetMenu16 can just call GetMenu.
diff --git a/controls/menu.c b/controls/menu.c
index d263c18..412fa52 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -3859,17 +3859,7 @@
*/
HMENU16 WINAPI GetMenu16( HWND16 hWnd )
{
- HMENU16 retvalue;
- WND * wndPtr = WIN_FindWndPtr(hWnd);
- if (wndPtr && !(wndPtr->dwStyle & WS_CHILD))
- {
- retvalue = (HMENU16)wndPtr->wIDmenu;
- goto END;
-}
- retvalue = 0;
-END:
- WIN_ReleaseWndPtr(wndPtr);
- return retvalue;
+ return (HMENU16)GetMenu(hWnd);
}
@@ -3910,6 +3900,13 @@
TRACE("(%04x, %04x);\n", hWnd, hMenu);
+ if (hMenu && !IsMenu(hMenu))
+ {
+ WARN("hMenu is not a menu handle\n");
+ return FALSE;
+ }
+
+
if (wndPtr && !(wndPtr->dwStyle & WS_CHILD))
{
if (GetCapture() == hWnd) ReleaseCapture();