summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Src/input.c9
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 <p.stephenson@samsung.com>
+
+ * 34563: Src/input.c: Fix up memory allocation in 34560.
+
2015-02-16 Peter Stephenson <p.stephenson@samsung.com>
- * 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;