From 691547cda60f0512c645e80246292936e660f326 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Wed, 29 Oct 2014 08:45:57 -0700 Subject: 33563: Completion/Base/Core/_main_complete, Src/Zle/complist.c: fix thinko in status message for INT/QUIT signals; check errflag in output loops Two semi-related patches for keyboard interrupt handling in completion, most importantly so that unexpectedly long completion listings can be interrupted. --- Src/Zle/complist.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 5e5ba9f20..2e1a5273c 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -1375,7 +1375,7 @@ compprintlist(int showall) tcout(TCCLEAREOD); g = ((lasttype && lastg) ? lastg : amatches); - while (g) { + while (g && !errflag) { char **pp = g->ylist; #ifdef ZSH_HEAP_DEBUG @@ -1389,7 +1389,7 @@ compprintlist(int showall) ml = lastml; lastused = 1; } - while (*e) { + while (*e && !errflag) { if (((*e)->count || (*e)->always) && (!listdat.onlyexpl || (listdat.onlyexpl & ((*e)->always > 0 ? 2 : 1)))) { @@ -1469,11 +1469,11 @@ compprintlist(int showall) nl = nc = g->lins; - while (n && nl--) { + while (n && nl-- && !errflag) { i = g->cols; mc = 0; pq = pp; - while (n && i--) { + while (n && i-- && !errflag) { if (pq - g->ylist >= g->lcount) break; if (compzputs(*pq, mscroll)) @@ -1582,7 +1582,7 @@ compprintlist(int showall) } else p = skipnolist(g->matches, showall); - while (n && nl--) { + while (n && nl-- && !errflag) { if (!lasttype && ml >= mlbeg) { lasttype = 3; lastg = g; @@ -1596,7 +1596,7 @@ compprintlist(int showall) i = g->cols; mc = 0; q = p; - while (n && i--) { + while (n && i-- && !errflag) { wid = (g->widths ? g->widths[mc] : g->width); if (!(m = *q)) { if (clprintm(g, NULL, mc, ml, (!i), wid)) -- cgit v1.2.3 From 0d4b548d1e4a08105597791fd6308d7fd70d3ddf Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Sun, 30 Nov 2014 23:19:55 +0100 Subject: 33818: fix types passed to sizeof detected by coverity as being wrong --- ChangeLog | 6 ++++++ Src/Builtins/sched.c | 2 +- Src/Zle/complist.c | 4 ++-- Src/exec.c | 4 ++-- Src/sort.c | 2 +- Src/utils.c | 6 +++--- 6 files changed, 15 insertions(+), 9 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index 2a308a37e..fed76e508 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-11-30 Oliver Kiddle + + * 33818: Src/Builtins/sched.c, Src/Zle/complist.c, + Src/exec.c, Src/sort.c, Src/utils.c: fix types passed to sizeof + detected by coverity as being wrong + 2014-11-28 Barton E. Schaefer * 33819: Test/A06assign.ztst: regression tests for 33816 diff --git a/Src/Builtins/sched.c b/Src/Builtins/sched.c index c1cc98354..bcf7661f4 100644 --- a/Src/Builtins/sched.c +++ b/Src/Builtins/sched.c @@ -346,7 +346,7 @@ schedgetfn(UNUSED(Param pm)) for (i = 0, sch = schedcmds; sch; sch = sch->next, i++) ; - aptr = ret = zhalloc(sizeof(char **) * (i+1)); + aptr = ret = zhalloc(sizeof(char *) * (i+1)); for (sch = schedcmds; sch; sch = sch->next, aptr++) { char tbuf[40], *flagstr; time_t t; diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 2e1a5273c..c129940f7 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -2059,8 +2059,8 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) i = zterm_columns * listdat.nlines; free(mtab); - mtab = (Cmatch **) zalloc(i * sizeof(Cmatch **)); - memset(mtab, 0, i * sizeof(Cmatch **)); + mtab = (Cmatch **) zalloc(i * sizeof(Cmatch *)); + memset(mtab, 0, i * sizeof(Cmatch *)); free(mgtab); mgtab = (Cmgroup *) zalloc(i * sizeof(Cmgroup)); #ifdef DEBUG diff --git a/Src/exec.c b/Src/exec.c index 2b7c55f8f..a5f877191 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2299,13 +2299,13 @@ addvars(Estate state, Wordcode pc, int addflags) continue; } if (vl) { - ptr = arr = (char **) zalloc(sizeof(char **) * + ptr = arr = (char **) zalloc(sizeof(char *) * (countlinknodes(vl) + 1)); while (nonempty(vl)) *ptr++ = ztrdup((char *) ugetnode(vl)); } else - ptr = arr = (char **) zalloc(sizeof(char **)); + ptr = arr = (char **) zalloc(sizeof(char *)); *ptr = NULL; if (xtr) { diff --git a/Src/sort.c b/Src/sort.c index 3d00bb576..92ee1c0d4 100644 --- a/Src/sort.c +++ b/Src/sort.c @@ -368,7 +368,7 @@ strmetasort(char **array, int sortwhat, int *unmetalenp) sortdir = (sortwhat & SORTIT_BACKWARDS) ? -1 : 1; sortnumeric = (sortwhat & SORTIT_NUMERICALLY) ? 1 : 0; - qsort(sortptrarr, nsort, sizeof(SortElt *), eltpcmp); + qsort(sortptrarr, nsort, sizeof(SortElt), eltpcmp); sortnumeric = oldsortnumeric; sortdir = oldsortdir; diff --git a/Src/utils.c b/Src/utils.c index 5f0c1062b..926814759 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -693,12 +693,12 @@ slashsplit(char *s) int t0; if (!*s) - return (char **) zshcalloc(sizeof(char **)); + return (char **) zshcalloc(sizeof(char *)); for (t = s, t0 = 0; *t; t++) if (*t == '/') t0++; - q = r = (char **) zalloc(sizeof(char **) * (t0 + 2)); + q = r = (char **) zalloc(sizeof(char *) * (t0 + 2)); while ((t = strchr(s, '/'))) { *q++ = ztrduppfx(s, t - s); @@ -2955,7 +2955,7 @@ colonsplit(char *s, int uniq) for (t = s, ct = 0; *t; t++) /* count number of colons */ if (*t == ':') ct++; - ptr = ret = (char **) zalloc(sizeof(char **) * (ct + 2)); + ptr = ret = (char **) zalloc(sizeof(char *) * (ct + 2)); t = s; do { -- cgit v1.2.3 From fe51f39dadfc2a1651ac92edfb783f1e6100b7b1 Mon Sep 17 00:00:00 2001 From: Jun-ichi Takimoto Date: Thu, 18 Dec 2014 03:49:51 +0900 Subject: 33978: avoid infinite loop in interactive mode Update command line when accept-and-hold is called in the interactive mode of menu select. --- ChangeLog | 5 +++++ Src/Zle/complist.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index ee3e8207a..1911ec9d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-18 Jun-ichi Takimoto + + * 33978: Src/Zle/complist.c: update command line when accept- + and-hold is called in interactive mode of menu select + 2014-12-17 Peter Stephenson * users/19551: Doc/builtins.yo, Doc/Zsh/roadmap.yo: better diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index c129940f7..b6e7e30e9 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -2790,7 +2790,9 @@ domenuselect(Hookdef dummy, Chdata dat) Menustack s = (Menustack) zhalloc(sizeof(*s)); int ol; - mode = 0; + if (mode == MM_INTER) + do_single(*minfo.cur); + mode = 0; s->prev = u; u = s; s->line = dupstring(zlemetaline); -- cgit v1.2.3 From 8035794a56eec3539fb1080ca3818237ed504349 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Mon, 5 Jan 2015 14:20:06 +0100 Subject: 34119: complist: Fix leak of string in clnicezputs Found by Coverity (Issue 1255808). --- ChangeLog | 2 ++ Src/Zle/complist.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index 72013066d..4f58df1fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2015-01-06 Mikael Magnusson + * 34119: Src/Zle/complist.c: Fix leak of string in clnicezputs + * 34105: Src/subst.c: remove dead code * 34121: Src/Zle/compresult.c: Remove unneeded NULL check diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index b6e7e30e9..80e5bf9d1 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -780,6 +780,7 @@ clnicezputs(int do_colors, char *s, int ml) /* Is the screen full? */ if (ml == mlend - 1 && col == zterm_columns - 1) { mlprinted = ml - oml; + free(ums); return 0; } if (t < wptr) { @@ -804,6 +805,7 @@ clnicezputs(int do_colors, char *s, int ml) ml++; if (mscroll && !--mrestlines && (ask = asklistscroll(ml))) { mlprinted = ml - oml; + free(ums); return ask; } col -= zterm_columns; -- cgit v1.2.3 From 152b7975968cea9e11f707ca5e1a233c9de99cf7 Mon Sep 17 00:00:00 2001 From: Jun-ichi Takimoto Date: Wed, 7 Jan 2015 21:48:28 +0900 Subject: 34144: allocate origline by ztrdup(), not by dupstring() If origline is allocated in heap, it will have been freed when menuselect() is called directly as a widget. --- ChangeLog | 5 +++++ Src/Zle/complist.c | 6 ++++-- Src/Zle/zle_tricky.c | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'Src/Zle/complist.c') diff --git a/ChangeLog b/ChangeLog index d31095b70..b5710fa6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-07 Jun-ichi Takimoto + + * 34144: Src/Zle/zle_tricky.c, Src/Zle/complist.c: allocate + origline by ztrdup(), not by dupstring() + 2015-01-06 Barton E. Schaefer * 34122: Src/module.c: allow NULL third argument as intended diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 80e5bf9d1..f54206619 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -2884,7 +2884,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); @@ -3238,7 +3239,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 864f804b7..950c22f38 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)) { -- cgit v1.2.3