aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-09 18:04:18 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-09 18:04:18 +0300
commit24ddf2742b0034089bce38e5f4ebd99b93c6e161 (patch)
treef1bebfcf20d78673b656122b0258c5054a999562 /debug.c
parent9091a155190093c3d2dbbed4bd29b0feec50c8ce (diff)
downloadegawk-24ddf2742b0034089bce38e5f4ebd99b93c6e161.tar.gz
egawk-24ddf2742b0034089bce38e5f4ebd99b93c6e161.tar.bz2
egawk-24ddf2742b0034089bce38e5f4ebd99b93c6e161.zip
Further fixes from Andrew Schorr.
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/debug.c b/debug.c
index c2f11355..6aaba099 100644
--- a/debug.c
+++ b/debug.c
@@ -4205,10 +4205,10 @@ gprintf(FILE *fp, const char *format, ...)
#define GPRINTF_BUFSIZ 512
if (buf == NULL) {
buflen = GPRINTF_BUFSIZ;
- emalloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
+ emalloc(buf, char *, buflen * sizeof(char), "gprintf");
} else if (buflen - bl < GPRINTF_BUFSIZ/2) {
buflen += GPRINTF_BUFSIZ;
- erealloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
+ erealloc(buf, char *, buflen * sizeof(char), "gprintf");
}
#undef GPRINTF_BUFSIZ
@@ -4227,7 +4227,7 @@ gprintf(FILE *fp, const char *format, ...)
/* enlarge buffer, and try again */
buflen *= 2;
- erealloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
+ erealloc(buf, char *, buflen * sizeof(char), "gprintf");
}
bl = 0;
@@ -4267,7 +4267,7 @@ gprintf(FILE *fp, const char *format, ...)
static int
serialize_subscript(char *buf, int buflen, struct list_item *item)
{
- int bl = 0, nchar, i;
+ int bl, nchar, i;
NODE *sub;
nchar = snprintf(buf, buflen, "%d%c%d%c%s%c%d%c",
@@ -4277,7 +4277,7 @@ serialize_subscript(char *buf, int buflen, struct list_item *item)
return 0;
else if (nchar >= buflen) /* need larger buffer */
return nchar;
- bl += nchar;
+ bl = nchar;
for (i = 0; i < item->num_subs; i++) {
sub = item->subs[i];
nchar = snprintf(buf + bl, buflen - bl, "%lu%c%s%c",