aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin.c b/builtin.c
index b8e24cb3..eb823ac1 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2955,13 +2955,16 @@ set_how_many:
done:
DEREF(s);
- if ((matches == 0 || (flags & LITERAL) != 0) && buf != NULL)
+ if ((matches == 0 || (flags & LITERAL) != 0) && buf != NULL) {
efree(buf);
+ buf = NULL;
+ }
if (flags & GENSUB) {
if (matches > 0) {
/* return the result string */
DEREF(t);
+ assert(buf != NULL);
return make_str_node(buf, textlen, ALREADY_MALLOCED);
}