From c54a8ebdc993aa3bf259fa7ab85a0f077a70040c Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 2 Feb 2017 15:42:25 +0200 Subject: Improve memory hygiene in set_profile_text. --- awkgram.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'awkgram.c') diff --git a/awkgram.c b/awkgram.c index 5b55cf51..fb6e4825 100644 --- a/awkgram.c +++ b/awkgram.c @@ -8713,7 +8713,8 @@ set_profile_text(NODE *n, const char *str, size_t len) { if (do_pretty_print) { // extra byte in case need to add minus sign in negate_num - n->stptr = estrdup(str, len + 1); + // and another one for the \0 at the end + n->stptr = estrdup(str, len + 2); n->stptr[len] = '\0'; n->stlen = len; // Set STRCUR and n->stfmt for use when profiling -- cgit v1.2.3