diff options
author | Mathias Gumz <akira@fluxbox.org> | 2015-01-16 09:36:14 (GMT) |
---|---|---|
committer | Mathias Gumz <akira@fluxbox.org> | 2015-01-16 09:36:14 (GMT) |
commit | df996370d0f6c606e5135bb0a461514f46532195 (patch) | |
tree | 144b8427696339259e1f38a19b2ed9c18666aba1 | |
parent | b30438c311a356f7bb1621f1ed3cb9a99e7d96c9 (diff) | |
download | fluxbox-df996370d0f6c606e5135bb0a461514f46532195.zip fluxbox-df996370d0f6c606e5135bb0a461514f46532195.tar.bz2 |
Fix leak in ClientPatternTestCmd
Coverity-scan points to the leaking ClientPattern. The rest is just
cosmetics.
-rw-r--r-- | src/FbCommands.cc | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 0708b1e..3201fc3 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc | |||
@@ -42,17 +42,8 @@ | |||
42 | #include <fstream> | 42 | #include <fstream> |
43 | #include <iostream> | 43 | #include <iostream> |
44 | #include <set> | 44 | #include <set> |
45 | 45 | #include <cstdlib> | |
46 | #ifdef HAVE_CSTDLIB | 46 | #include <cstring> |
47 | #include <cstdlib> | ||
48 | #else | ||
49 | #include <stdlib.h> | ||
50 | #endif | ||
51 | #ifdef HAVE_CSTRING | ||
52 | #include <cstring> | ||
53 | #else | ||
54 | #include <string.h> | ||
55 | #endif | ||
56 | 47 | ||
57 | #if defined(__EMX__) && defined(HAVE_PROCESS_H) | 48 | #if defined(__EMX__) && defined(HAVE_PROCESS_H) |
58 | #include <process.h> // for P_NOWAIT | 49 | #include <process.h> // for P_NOWAIT |
@@ -78,16 +69,18 @@ void showMenu(BScreen &screen, FbTk::Menu &menu) { | |||
78 | 69 | ||
79 | FbMenu::setWindow(FocusControl::focusedFbWindow()); | 70 | FbMenu::setWindow(FocusControl::focusedFbWindow()); |
80 | 71 | ||
81 | Window ignored_w; | 72 | union { |
82 | int ignored_i; | 73 | Window w; |
83 | unsigned int ignored_ui; | 74 | int i; |
75 | unsigned int ui; | ||
76 | } ignored; | ||
84 | 77 | ||
85 | int x = 0; | 78 | int x = 0; |
86 | int y = 0; | 79 | int y = 0; |
87 | 80 | ||
88 | XQueryPointer(menu.fbwindow().display(), | 81 | XQueryPointer(menu.fbwindow().display(), |
89 | screen.rootWindow().window(), &ignored_w, &ignored_w, | 82 | screen.rootWindow().window(), &ignored.w, &ignored.w, |
90 | &x, &y, &ignored_i, &ignored_i, &ignored_ui); | 83 | &x, &y, &ignored.i, &ignored.i, &ignored.ui); |
91 | 84 | ||
92 | screen.placementStrategy() | 85 | screen.placementStrategy() |
93 | .placeAndShowMenu(menu, x, y, false); | 86 | .placeAndShowMenu(menu, x, y, false); |
@@ -546,7 +539,6 @@ void ClientPatternTestCmd::execute() { | |||
546 | std::string result; | 539 | std::string result; |
547 | std::string pat; | 540 | std::string pat; |
548 | int opts; | 541 | int opts; |
549 | ClientPattern* cp; | ||
550 | Display* dpy; | 542 | Display* dpy; |
551 | Atom atom_utf8; | 543 | Atom atom_utf8; |
552 | Atom atom_fbcmd_result; | 544 | Atom atom_fbcmd_result; |
@@ -558,9 +550,9 @@ void ClientPatternTestCmd::execute() { | |||
558 | atom_fbcmd_result = XInternAtom(dpy, "_FLUXBOX_ACTION_RESULT", False); | 550 | atom_fbcmd_result = XInternAtom(dpy, "_FLUXBOX_ACTION_RESULT", False); |
559 | 551 | ||
560 | FocusableList::parseArgs(m_args, opts, pat); | 552 | FocusableList::parseArgs(m_args, opts, pat); |
561 | cp = new ClientPattern(pat.c_str()); | 553 | ClientPattern cp(pat.c_str()); |
562 | 554 | ||
563 | if (!cp->error()) { | 555 | if (!cp.error()) { |
564 | 556 | ||
565 | const FocusableList* windows; | 557 | const FocusableList* windows; |
566 | FocusControl::Focusables::const_iterator wit; | 558 | FocusControl::Focusables::const_iterator wit; |
@@ -574,7 +566,7 @@ void ClientPatternTestCmd::execute() { | |||
574 | 566 | ||
575 | for ( ; wit != wit_end; wit++) { | 567 | for ( ; wit != wit_end; wit++) { |
576 | Focusable* f = *wit; | 568 | Focusable* f = *wit; |
577 | if (typeid(*f) == typeid(FluxboxWindow) && cp->match(*f)) { | 569 | if (typeid(*f) == typeid(FluxboxWindow) && cp.match(*f)) { |
578 | matches.push_back(static_cast<const FluxboxWindow*>(f)); | 570 | matches.push_back(static_cast<const FluxboxWindow*>(f)); |
579 | } | 571 | } |
580 | } | 572 | } |
@@ -594,7 +586,7 @@ void ClientPatternTestCmd::execute() { | |||
594 | } | 586 | } |
595 | } else { | 587 | } else { |
596 | result = "-1\t"; | 588 | result = "-1\t"; |
597 | result += FbTk::StringUtil::number2String(cp->error_col()); | 589 | result += FbTk::StringUtil::number2String(cp.error_col()); |
598 | result += "\n"; | 590 | result += "\n"; |
599 | } | 591 | } |
600 | 592 | ||