From 9b21dcada9d678da6d23c7e03c68eca926e3ff3e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 17 Feb 2015 09:56:09 +0000 Subject: Fix up memory allocation for previous patch --- ChangeLog | 8 +++++++- Src/input.c | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 509faffe6..df483c30d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ +2015-02-17 Peter Stephenson + + * 34563: Src/input.c: Fix up memory allocation in 34560. + 2015-02-16 Peter Stephenson - * 34560: Src/input. Src/lex.c, Src/zsh.h, Test/C01arith.ztst: + * 34560: Src/input. Src/lex.c, Src/zsh.h, Test/C01arith.ztst: + case of $(( that turned into a $(...) and a (...) with + multiple lines read before it found out. * 34558: Doc/Zsh/func.yo: preexec doc erroneously claimed $1 was empty if line removed from history. diff --git a/Src/input.c b/Src/input.c index f919e5757..92b1ad1f7 100644 --- a/Src/input.c +++ b/Src/input.c @@ -348,12 +348,13 @@ inputline(void) int oldlen = (int)(inbufptr - inbuf) + inbufleft; if (inbufflags & INP_FREE) { inbuf = realloc(inbuf, oldlen + newlen + 1); - inbufptr += inbuf - oinbuf; - strcpy(inbuf + oldlen, ingetcline); } else { - /* Paranoia: don't think this is used */ - DPUTS(1, "Appending to unallocated input line."); + inbuf = zalloc(oldlen + newlen + 1); + memcpy(inbuf, oinbuf, oldlen); } + inbufptr += inbuf - oinbuf; + strcpy(inbuf + oldlen, ingetcline); + free(ingetcline); inbufleft += newlen; inbufct += newlen; inbufflags |= INP_FREE; -- cgit 1.4.1