The branch, master has been updated
       via  362c4607671621c4f4265a0089dd1d313e2b7608 (commit)
       via  f4c815a1d9bb6c5b16a9f83d6e43c1d183a7f8d1 (commit)
      from  fc6f08d5b71db219a96fd15a8befac88d2f4bca3 (commit)

- Log -----------------------------------------------------------------
commit 362c4607671621c4f4265a0089dd1d313e2b7608
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Do not crash when calling choose-tree with a command that changes the mode.
---
 cmd.c           |    2 +-
 window-choose.c |   24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/cmd.c b/cmd.c
index fae5b45..52c1a30 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1228,7 +1228,7 @@ cmd_template_replace(const char *template, const char *s, 
int idx)
        int              replaced;
        size_t           len;
 
-       if (strstr(template, "%") == NULL)
+       if (strchr(template, '%') == NULL)
                return (xstrdup(template));
 
        buf = xmalloc(1);
diff --git a/window-choose.c b/window-choose.c
index 644318a..9aab652 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -77,6 +77,7 @@ struct window_choose_mode_data {
        void                    (*callbackfn)(struct window_choose_data *);
 };
 
+void   window_choose_free1(struct window_choose_mode_data *);
 int     window_choose_key_index(struct window_choose_mode_data *, u_int);
 int     window_choose_index_key(struct window_choose_mode_data *, int);
 void   window_choose_prompt_input(enum window_choose_input_type,
@@ -246,10 +247,19 @@ window_choose_default_callback(struct window_choose_data 
*wcd)
 void
 window_choose_free(struct window_pane *wp)
 {
-       struct window_choose_mode_data  *data = wp->modedata;
+       if (wp->modedata != NULL)
+               window_choose_free1(wp->modedata);
+}
+
+void
+window_choose_free1(struct window_choose_mode_data *data)
+{
        struct window_choose_mode_item  *item;
        u_int                            i;
 
+       if (data == NULL)
+               return;
+
        for (i = 0; i < ARRAY_LENGTH(&data->old_list); i++) {
                item = &ARRAY_ITEM(&data->old_list, i);
                window_choose_data_free(item->wcd);
@@ -282,14 +292,13 @@ window_choose_fire_callback(
     struct window_pane *wp, struct window_choose_data *wcd)
 {
        struct window_choose_mode_data  *data = wp->modedata;
-       const struct window_mode        *oldmode;
 
-       oldmode = wp->mode;
-       wp->mode = NULL;
+       wp->modedata = NULL;
+       window_pane_reset_mode(wp);
 
        data->callbackfn(wcd);
 
-       wp->mode = oldmode;
+       window_choose_free1(data);
 }
 
 void
@@ -500,7 +509,6 @@ window_choose_key(struct window_pane *wp, unused struct 
session *sess, int key)
                        }
                        item = &ARRAY_ITEM(&data->list, n);
                        window_choose_fire_callback(wp, item->wcd);
-                       window_pane_reset_mode(wp);
                        break;
                case MODEKEYCHOICE_BACKSPACE:
                        input_len = strlen(data->input_str);
@@ -521,12 +529,10 @@ window_choose_key(struct window_pane *wp, unused struct 
session *sess, int key)
        switch (mode_key_lookup(&data->mdata, key)) {
        case MODEKEYCHOICE_CANCEL:
                window_choose_fire_callback(wp, NULL);
-               window_pane_reset_mode(wp);
                break;
        case MODEKEYCHOICE_CHOOSE:
                item = &ARRAY_ITEM(&data->list, data->selected);
                window_choose_fire_callback(wp, item->wcd);
-               window_pane_reset_mode(wp);
                break;
        case MODEKEYCHOICE_TREE_TOGGLE:
                item = &ARRAY_ITEM(&data->list, data->selected);
@@ -676,7 +682,6 @@ window_choose_key(struct window_pane *wp, unused struct 
session *sess, int key)
 
                item = &ARRAY_ITEM(&data->list, data->selected);
                window_choose_fire_callback(wp, item->wcd);
-               window_pane_reset_mode(wp);
                break;
        }
 }
@@ -705,7 +710,6 @@ window_choose_mouse(
 
        item = &ARRAY_ITEM(&data->list, data->selected);
        window_choose_fire_callback(wp, item->wcd);
-       window_pane_reset_mode(wp);
 }
 
 void


commit f4c815a1d9bb6c5b16a9f83d6e43c1d183a7f8d1
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Fix constness again, sigh.
---
 cmd.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd.c b/cmd.c
index d30279a..fae5b45 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1223,10 +1223,10 @@ cmd_find_pane_offset(const char *paneptr, struct 
winlink *wl)
 char *
 cmd_template_replace(const char *template, const char *s, int idx)
 {
-       char     ch;
-       char    *buf, *ptr;
-       int      replaced;
-       size_t   len;
+       char             ch, *buf;
+       const char      *ptr;
+       int              replaced;
+       size_t           len;
 
        if (strstr(template, "%") == NULL)
                return (xstrdup(template));


-----------------------------------------------------------------------

Summary of changes:
 cmd.c           |   10 +++++-----
 window-choose.c |   24 ++++++++++++++----------
 2 files changed, 19 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to