From d60f73f7081a327fc6d6b9f988c763ab7b228f74 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 3 Mar 2009 22:11:37 +0000 Subject: 26686: problem storing long $_ using VARARR() --- Src/exec.c | 18 +++++++++++++----- Src/utils.c | 13 ++++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'Src') diff --git a/Src/exec.c b/Src/exec.c index b86e5350c..ed7c08759 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -4431,10 +4431,12 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) mod_export void runshfunc(Eprog prog, FuncWrap wrap, char *name) { - int cont; - VARARR(char, ou, underscoreused); + int cont, ouu; + char *ou; - memcpy(ou, underscore, underscoreused); + ou = zalloc(ouu = underscoreused); + if (ou) + memcpy(ou, underscore, underscoreused); while (wrap) { wrap->module->wrapper++; @@ -4445,13 +4447,19 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name) (wrap->module->node.flags & MOD_UNLOAD)) unload_module(wrap->module); - if (!cont) + if (!cont) { + if (ou) + zfree(ou, ouu); return; + } wrap = wrap->next; } startparamscope(); execode(prog, 1, 0); - setunderscore(ou); + if (ou) { + setunderscore(ou); + zfree(ou, ouu); + } endparamscope(); } diff --git a/Src/utils.c b/Src/utils.c index fbe1eb223..7a983d48d 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1340,9 +1340,13 @@ checkmailpath(char **s) fprintf(shout, "You have new mail.\n"); fflush(shout); } else { - VARARR(char, usav, underscoreused); + char *usav; + int uusav = underscoreused; - memcpy(usav, underscore, underscoreused); + usav = zalloc(underscoreused); + + if (usav) + memcpy(usav, underscore, underscoreused); setunderscore(*s); @@ -1353,7 +1357,10 @@ checkmailpath(char **s) fputc('\n', shout); fflush(shout); } - setunderscore(usav); + if (usav) { + setunderscore(usav); + zfree(usav, uusav); + } } } if (isset(MAILWARNING) && st.st_atime > st.st_mtime && -- cgit 1.4.1