From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12294 invoked by alias); 6 Jan 2015 17:21:49 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34144 Received: (qmail 11528 invoked from network); 6 Jan 2015 17:21:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Biglobe-Sender: From: "Jun T." Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: [PATCH] allocate origline by ztrdup(), not by dupstring() Message-Id: <1000D010-B07A-4F19-A566-8CA95B061D58@kba.biglobe.ne.jp> Date: Wed, 7 Jan 2015 01:37:01 +0900 To: zsh-workers@zsh.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-Biglobe-Spnum: 61614 Currently, domenuselect() allocates origline in heap by dupstring(), but if menuselect() is called directly as a widget then the heap has already been freed (and may have been re-used for other variables). --- Src/Zle/complist.c | 6 ++++-- Src/Zle/zle_tricky.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index b6e7e30..8850506 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -2882,7 +2882,8 @@ domenuselect(Hookdef dummy, Chdata dat) brend = dupbrinfo(u->brend, &lastbrend, 0); nbrbeg = u->nbrbeg; nbrend = u->nbrend; - origline = u->origline; + zsfree(origline); + origline = ztrdup(u->origline); origcs = u->origcs; origll = u->origll; strcpy(status, u->status); @@ -3236,7 +3237,8 @@ domenuselect(Hookdef dummy, Chdata dat) * don't want that, just what the user typed, * so restore the information. */ - origline = modeline; + zsfree(origline); + origline = ztrdup(modeline); origcs = modecs; origll = modell; zlemetacs = 0; diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 864f804..950c22f 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -634,7 +634,8 @@ docomplete(int lst) metafy_line(); ocs = zlemetacs; - origline = dupstring(zlemetaline); + zsfree(origline); + origline = ztrdup(zlemetaline); origcs = zlemetacs; origll = zlemetall; if (!isfirstln && (chline != NULL || zle_chline != NULL)) { -- 1.9.3 (Apple Git-50)