zsh/724fd07a67f135c74eba57e9f25fd342201ec722.patch
Ismail Dönmez d4737238b5 - Fix license to be MIT, zsh seems to be using the "Modern" variant
of the license text.
- Import git commits 74eed99c312de05e19b54ba6b5d37a0aeb4ba713 and
  724fd07a67f135c74eba57e9f25fd342201ec722
  * metafy() added null termination even if buffer was not modifiable
  * Fix uninitialised memory after lexer realloc

OBS-URL: https://build.opensuse.org/package/show/shells/zsh?expand=0&rev=87
2011-12-05 09:43:11 +00:00

36 lines
880 B
Diff

commit 724fd07a67f135c74eba57e9f25fd342201ec722
Author: Peter Stephenson <pws@users.sourceforge.net>
Date: Sat Dec 3 17:24:45 2011 +0000
29934: Stef van Vlierberghe: uninitialised memory after lexer realloc
diff --git a/Src/lex.c b/Src/lex.c
index 90c4eff..05f54f8 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -567,22 +567,14 @@ add(int c)
{
*bptr++ = c;
if (bsiz == ++len) {
-#if 0
- int newbsiz;
-
- newbsiz = bsiz * 8;
- while (newbsiz < inbufct)
- newbsiz *= 2;
- bptr = len + (tokstr = (char *)hrealloc(tokstr, bsiz, newbsiz));
- bsiz = newbsiz;
-#endif
-
int newbsiz = bsiz * 2;
if (newbsiz > inbufct && inbufct > bsiz)
newbsiz = inbufct;
bptr = len + (tokstr = (char *)hrealloc(tokstr, bsiz, newbsiz));
+ /* len == bsiz, so bptr is at the start of newly allocated memory */
+ memset(bptr, 0, newbsiz - bsiz);
bsiz = newbsiz;
}
}