summary refs log tree commit diff
path: root/Src/input.c
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 /Src/input.c
parent126fb61c7c48edb19b9d771e4e517cef710f8bf1 (diff)
downloadzsh-9b21dcada9d678da6d23c7e03c68eca926e3ff3e.tar.gz
zsh-9b21dcada9d678da6d23c7e03c68eca926e3ff3e.tar.xz
zsh-9b21dcada9d678da6d23c7e03c68eca926e3ff3e.zip
Fix up memory allocation for previous patch
Diffstat (limited to 'Src/input.c')
-rw-r--r--Src/input.c9
1 files changed, 5 insertions, 4 deletions
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;