summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/window-tree.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-04-30 06:19:52 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-04-30 06:19:52 +0000
commitf23899246fe93d2e7eeaa84c162e649c3e6f142e (patch)
treec345143f3e6975ff4f2ec6a4278cdd6b2caa6778 /usr.bin/tmux/window-tree.c
parenta5d052e4e7e7e89c50d1286ac7536a5ad53f2e47 (diff)
Fix memory leak in window tree search, from Amos Bird.
Diffstat (limited to 'usr.bin/tmux/window-tree.c')
-rw-r--r--usr.bin/tmux/window-tree.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/tmux/window-tree.c b/usr.bin/tmux/window-tree.c
index 4d1f603dfbc..daae6dab492 100644
--- a/usr.bin/tmux/window-tree.c
+++ b/usr.bin/tmux/window-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-tree.c,v 1.36 2019/04/17 14:37:48 nicm Exp $ */
+/* $OpenBSD: window-tree.c,v 1.37 2019/04/30 06:19:51 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -785,7 +785,8 @@ window_tree_search(__unused void *modedata, void *itemdata, const char *ss)
struct session *s;
struct winlink *wl;
struct window_pane *wp;
- const char *cmd;
+ char *cmd;
+ int retval;
window_tree_pull_item(item, &s, &wl, &wp);
@@ -806,7 +807,9 @@ window_tree_search(__unused void *modedata, void *itemdata, const char *ss)
cmd = get_proc_name(wp->fd, wp->tty);
if (cmd == NULL || *cmd == '\0')
return (0);
- return (strstr(cmd, ss) != NULL);
+ retval = (strstr(cmd, ss) != NULL);
+ free(cmd);
+ return retval;
}
return (0);
}