aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.y
diff options
context:
space:
mode:
Diffstat (limited to 'awkgram.y')
-rw-r--r--awkgram.y10
1 files changed, 5 insertions, 5 deletions
diff --git a/awkgram.y b/awkgram.y
index 0ce7b833..b69aa059 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2202,11 +2202,9 @@ negate_num(NODE *n)
if ((n->flags & NUMCONSTSTR) != 0) {
char *s;
- emalloc(s, char *, n->stlen + 1 + 1, "negate_num");
+ s = n->stptr;
+ memmove(& s[1], & s[0], n->stlen + 1);
s[0] = '-';
- strcpy(& s[1], n->stptr);
- free(n->stptr);
- n->stptr = s;
n->stlen++;
}
@@ -6281,7 +6279,9 @@ make_profile_number(double d, const char *str, size_t len)
{
NODE *n = make_number(d);
if (do_pretty_print) {
- n->stptr = estrdup(str, len);
+ // extra byte in case need to add minus sign in negate_num
+ n->stptr = estrdup(str, len + 1);
+ n->stptr[len] = '\0';
n->stlen = len;
n->flags |= NUMCONSTSTR;
}