From c0ea4d62c81f7480192b1f61649f82d064dcb716 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Tue, 28 Aug 2001 08:41:51 +0000 Subject: handle possible NULL pointer returned from bufferwords() (15717) --- ChangeLog | 6 ++++++ Src/Modules/parameter.c | 6 +++--- Src/Zle/zle_misc.c | 12 ++++++------ Src/subst.c | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e146396d..6097f9093 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-08-28 Sven Wischnowsky + + * 15717: Src/subst.c, Src/Modules/parameter.c, + Src/Zle/zle_misc.c: handle possible NULL pointer returned from + bufferwords() + 2001-08-27 Wayne Davison * 15713: Completion/Redhat/Command/_rpm: added package-specification diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index fe44eafb3..23c868598 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -1105,9 +1105,9 @@ histwgetfn(Param pm) int i = addhistnum(curhist, -1, HIST_FOREIGN), iw; Histent he = gethistent(i, GETHIST_UPWARD); - ll = bufferwords(NULL, NULL, NULL); - for (n = firstnode(ll); n; incnode(n)) - pushnode(l, getdata(n)); + if ((ll = bufferwords(NULL, NULL, NULL))) + for (n = firstnode(ll); n; incnode(n)) + pushnode(l, getdata(n)); while (he) { for (iw = he->nwords - 1; iw >= 0; iw--) { diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c index 2a650af86..e24d0c08b 100644 --- a/Src/Zle/zle_misc.c +++ b/Src/Zle/zle_misc.c @@ -549,13 +549,13 @@ copyprevshellword(char **args) int i; char *p = NULL; - l = bufferwords(NULL, NULL, &i); + if ((l = bufferwords(NULL, NULL, &i))) + for (n = firstnode(l); n; incnode(n)) + if (!i--) { + p = getdata(n); + break; + } - for (n = firstnode(l); n; incnode(n)) - if (!i--) { - p = getdata(n); - break; - } if (p) { int len = strlen(p); diff --git a/Src/subst.c b/Src/subst.c index 0ef084106..8bd1a1ae3 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1833,7 +1833,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) } else list = bufferwords(NULL, val, NULL); - if (!firstnode(list)) + if (!list || !firstnode(list)) val = dupstring(""); else if (!nextnode(firstnode(list))) val = getdata(firstnode(list)); -- cgit 1.4.1