From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKm7G-0005Ze-20 for qemu-devel@nongnu.org; Thu, 30 Jul 2015 07:35:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKm7E-0002Hr-1H for qemu-devel@nongnu.org; Thu, 30 Jul 2015 07:35:13 -0400 Received: from e19.ny.us.ibm.com ([129.33.205.209]:54813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKm7D-0002Hh-T1 for qemu-devel@nongnu.org; Thu, 30 Jul 2015 07:35:11 -0400 Received: from /spool/local by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 30 Jul 2015 07:35:11 -0400 From: Michael Roth Date: Thu, 30 Jul 2015 06:32:38 -0500 Message-Id: <1438255988-10418-24-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1438255988-10418-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1438255988-10418-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 23/53] sdl2: fix crash in handle_windowevent() when restoring the screen size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alberto Garcia , qemu-stable@nongnu.org, Gerd Hoffmann From: Alberto Garcia The Ctrl-Alt-u keyboard shortcut restores the screen to its original size. In the SDL2 UI this is done by destroying the window and creating a new one. The old window emits SDL_WINDOWEVENT_HIDDEN when it's destroyed, but trying to call SDL_GetWindowFromID() from that event's window ID returns a null pointer. handle_windowevent() assumes that the pointer is never null so it results in a crash. Cc: qemu-stable@nongnu.org Signed-off-by: Alberto Garcia Signed-off-by: Gerd Hoffmann (cherry picked from commit 08d49df0dbaacc220a099dbfb644e1dc0eda57be) Signed-off-by: Michael Roth --- ui/sdl2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/sdl2.c b/ui/sdl2.c index 60e3c3b..f10c6a4 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -511,6 +511,10 @@ static void handle_windowevent(SDL_Event *ev) { struct sdl2_console *scon = get_scon_from_window(ev->window.windowID); + if (!scon) { + return; + } + switch (ev->window.event) { case SDL_WINDOWEVENT_RESIZED: { -- 1.9.1