From 67e2558310602af1b1fcf33cd256f9db8f2dfd35 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 11 Mar 2023 12:44:09 -0800
Subject: [PATCH] Check tooltip and popup window flags during parameter
validation
---
src/video/SDL_video.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index eac968e5caf9..a7d5687e9cb5 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1946,16 +1946,16 @@ SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y
/* Parent must be a valid window */
CHECK_WINDOW_MAGIC(parent, NULL);
- /* Remove invalid flags */
- flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MOUSE_GRABBED);
-
/* Popups must specify either the tooltip or popup menu window flags */
- if ((flags & SDL_WINDOW_TOOLTIP) || (flags & SDL_WINDOW_POPUP_MENU)) {
- return SDL_CreateWindowInternal(NULL, offset_x, offset_y, w, h, parent, flags);
+ if (!(flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU))) {
+ SDL_SetError("Popup windows must specify either the 'SDL_WINDOW_TOOLTIP' or the 'SDL_WINDOW_POPUP_MENU' flag");
+ return NULL;
}
- SDL_SetError("Popup windows must specify either the 'SDL_WINDOW_TOOLTIP' or the 'SDL_WINDOW_POPUP_MENU' flag");
- return NULL;
+ /* Remove invalid flags */
+ flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MOUSE_GRABBED);
+
+ return SDL_CreateWindowInternal(NULL, offset_x, offset_y, w, h, parent, flags);
}
SDL_Window *SDL_CreateWindowFrom(const void *data)