From 90d515f6e74634bdaef09e6540b75c56e797cdba Mon Sep 17 00:00:00 2001 From: sniperbeamer Date: Tue, 24 Jun 2008 17:05:24 +0000 Subject: [PATCH] Added safety check when retrieving the active window title for global auto-type git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@207 b624d157-de02-0410-bad0-e51aec6abb33 --- src/lib/AutoType_X11.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/AutoType_X11.cpp b/src/lib/AutoType_X11.cpp index 24075a7..01d56bd 100644 --- a/src/lib/AutoType_X11.cpp +++ b/src/lib/AutoType_X11.cpp @@ -170,20 +170,21 @@ void AutoType::performGlobal(){ Window w; int revert_to_return; XGetInputFocus(d, &w, &revert_to_return); - char** list; + char** list = NULL; int tree; do { XTextProperty textProp; - XGetWMName(d, w, &textProp); - int count; - Xutf8TextPropertyToTextList(d, &textProp, &list, &count); - if (list) break; + if (XGetWMName(d, w, &textProp) != 0) { + int count; + if (Xutf8TextPropertyToTextList(d, &textProp, &list, &count)<0) return; + if (list) break; + } Window root = 0; Window parent = 0; Window* children = NULL; unsigned int num_children; tree = XQueryTree(d, w, &root, &parent, &children, &num_children); - w=parent; + w = parent; if (children) XFree(children); } while (tree && w); if (!list) return;