From e414da37a116f76dcd35a50569050da9dc0024fa Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 16 Aug 2010 09:31:38 +0000 Subject: [PATCH] CID 1584 : NULL dereference on low memory situations (get_window_info does a malloc that may fail) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38134 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/screenshot/Screenshot.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/apps/screenshot/Screenshot.cpp b/src/apps/screenshot/Screenshot.cpp index 245cacd2e5..cd2ce77e5f 100644 --- a/src/apps/screenshot/Screenshot.cpp +++ b/src/apps/screenshot/Screenshot.cpp @@ -300,17 +300,18 @@ Screenshot::_GetActiveWindowFrame() foundActiveWindow = true; } else if (reply.FindBool("result", &foundActiveWindow) != B_OK) foundActiveWindow = false; - + if (foundActiveWindow) { // Get the client_window_info of the active window foundActiveWindow = false; for (int i = 0; i < tokenCount; i++) { token = tokens[i]; windowInfo = get_window_info(token); - if (!windowInfo->is_mini && !windowInfo->show_hide_level > 0) { + if (windowInfo && !windowInfo->is_mini + && !windowInfo->show_hide_level > 0) { foundActiveWindow = true; break; - } + } free(windowInfo); } if (foundActiveWindow)