summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-02-17 09:56:09 +0000
committerPeter Stephenson <pws@zsh.org>2015-02-17 09:56:09 +0000
commit9b21dcada9d678da6d23c7e03c68eca926e3ff3e (patch)
tree889dfb77b0fca295e8a0eeeeba043002be4e10f6
parent126fb61c7c48edb19b9d771e4e517cef710f8bf1 (diff)
downloadzsh-9b21dcada9d678da6d23c7e03c68eca926e3ff3e.tar.gz
zsh-9b21dcada9d678da6d23c7e03c68eca926e3ff3e.zip
Fix up memory allocation for previous patch
-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;