summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/lex.c12
-rw-r--r--Src/utils.c4
2 files changed, 4 insertions, 12 deletions
diff --git a/Src/lex.c b/Src/lex.c
index 90c4effd9..05f54f842 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;
}
}
diff --git a/Src/utils.c b/Src/utils.c
index 6c2ea98d5..014cb2fa2 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3959,7 +3959,7 @@ metafy(char *buf, int len, int heap)
if (imeta(*e++))
meta++;
- if (meta || heap == META_DUP || heap == META_HEAPDUP) {
+ if (meta || heap == META_DUP || heap == META_HEAPDUP || *e != '\0') {
switch (heap) {
case META_REALLOC:
buf = zrealloc(buf, len + meta + 1);
@@ -4002,8 +4002,8 @@ metafy(char *buf, int len, int heap)
meta--;
}
}
+ *e = '\0';
}
- *e = '\0';
return buf;
}