all repos — fluxbox @ df996370d0f6c606e5135bb0a461514f46532195

custom fork of the fluxbox windowmanager

Fix leak in ClientPatternTestCmd

Coverity-scan points to the leaking ClientPattern. The rest is just
cosmetics.
Mathias Gumz akira@fluxbox.org
commit

df996370d0f6c606e5135bb0a461514f46532195

parent

b30438c311a356f7bb1621f1ed3cb9a99e7d96c9

1 files changed, 13 insertions(+), 21 deletions(-)

jump to
M src/FbCommands.ccsrc/FbCommands.cc

@@ -42,17 +42,8 @@

#include <fstream> #include <iostream> #include <set> - -#ifdef HAVE_CSTDLIB - #include <cstdlib> -#else - #include <stdlib.h> -#endif -#ifdef HAVE_CSTRING - #include <cstring> -#else - #include <string.h> -#endif +#include <cstdlib> +#include <cstring> #if defined(__EMX__) && defined(HAVE_PROCESS_H) #include <process.h> // for P_NOWAIT

@@ -78,16 +69,18 @@ }

FbMenu::setWindow(FocusControl::focusedFbWindow()); - Window ignored_w; - int ignored_i; - unsigned int ignored_ui; + union { + Window w; + int i; + unsigned int ui; + } ignored; int x = 0; int y = 0; XQueryPointer(menu.fbwindow().display(), - screen.rootWindow().window(), &ignored_w, &ignored_w, - &x, &y, &ignored_i, &ignored_i, &ignored_ui); + screen.rootWindow().window(), &ignored.w, &ignored.w, + &x, &y, &ignored.i, &ignored.i, &ignored.ui); screen.placementStrategy() .placeAndShowMenu(menu, x, y, false);

@@ -546,7 +539,6 @@ std::vector< const FluxboxWindow* > matches;

std::string result; std::string pat; int opts; - ClientPattern* cp; Display* dpy; Atom atom_utf8; Atom atom_fbcmd_result;

@@ -558,9 +550,9 @@ atom_utf8 = XInternAtom(dpy, "UTF8_STRING", False);

atom_fbcmd_result = XInternAtom(dpy, "_FLUXBOX_ACTION_RESULT", False); FocusableList::parseArgs(m_args, opts, pat); - cp = new ClientPattern(pat.c_str()); + ClientPattern cp(pat.c_str()); - if (!cp->error()) { + if (!cp.error()) { const FocusableList* windows; FocusControl::Focusables::const_iterator wit;

@@ -574,7 +566,7 @@ wit_end = windows->clientList().end();

for ( ; wit != wit_end; wit++) { Focusable* f = *wit; - if (typeid(*f) == typeid(FluxboxWindow) && cp->match(*f)) { + if (typeid(*f) == typeid(FluxboxWindow) && cp.match(*f)) { matches.push_back(static_cast<const FluxboxWindow*>(f)); } }

@@ -594,7 +586,7 @@ result += "0\n";

} } else { result = "-1\t"; - result += FbTk::StringUtil::number2String(cp->error_col()); + result += FbTk::StringUtil::number2String(cp.error_col()); result += "\n"; }