Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Crash bug on garbage input (previously reported to Debian)
On Tue, 17 Feb 2015 10:02:14 +0100
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Coverity complains that ingetcline is not freed in the above path.
> +free(ingetcline); here?
Yes, that's missing, and we might as well handle the other branch now
it's working --- I didn't bother when fixing the bug but it's not
exactly difficult to do.
pws
diff --git a/Src/input.c b/Src/input.c
index f919e57..92b1ad1 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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author