Oops, looks like osdep_get_name can fail on Linux. Try this instead: diff --git a/format.c b/format.c index a7f1fde..118a8df 100644 --- a/format.c +++ b/format.c @@ -353,15 +353,20 @@ format_expand(struct format_tree *ft, const char *fmt) char * format_get_command(struct window_pane *wp) { - char *cmd; + char *cmd, *out; cmd = osdep_get_name(wp->fd, wp->tty); if (cmd == NULL || *cmd == '\0') { - cmd = wp->cmd; - if (cmd == NULL || *cmd == '\0') - cmd = wp->shell; + free(cmd); + cmd = xstrdup(wp->cmd); + if (cmd == NULL || *cmd == '\0') { + free(cmd); + cmd = xstrdup(wp->shell); + } } - return (parse_window_name(cmd)); + out = parse_window_name(cmd); + free(cmd); + return (out); } /* Set default format keys for a session. */
On Fri, Oct 11, 2013 at 02:07:49PM +1300, Jan Larres wrote: > On 11/10/13 12:29, Nicholas Marriott wrote: > > There is a leak in format_get_command but I don't see any others: > > > > diff --git a/format.c b/format.c > > index a7f1fde..2b00c3e 100644 > > --- a/format.c > > +++ b/format.c > > @@ -353,7 +353,7 @@ format_expand(struct format_tree *ft, const char *fmt) > > char * > > format_get_command(struct window_pane *wp) > > { > > - char *cmd; > > + char *cmd, *out; > > > > cmd = osdep_get_name(wp->fd, wp->tty); > > if (cmd == NULL || *cmd == '\0') { > > @@ -361,7 +361,9 @@ format_get_command(struct window_pane *wp) > > if (cmd == NULL || *cmd == '\0') > > cmd = wp->shell; > > } > > - return (parse_window_name(cmd)); > > + out = parse_window_name(cmd); > > + free(cmd); > > + return (out); > > } > > > > /* Set default format keys for a session. */ > > That patch crashes tmux for me when creating a few sessions and trying > to run a command in them. Sometimes it also seems to freeze instead. > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk > _______________________________________________ > tmux-users mailing list > tmux-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/tmux-users ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users