summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/sed')
-rw-r--r--usr.bin/sed/compile.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index 39aa80c..af281ae 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -138,7 +138,10 @@ compile()
*compile_stream(&prog) = NULL;
fixuplabel(prog, NULL);
uselabel();
- if ((appends = malloc(sizeof(struct s_appends) * appendnum)) == NULL)
+ if (appendnum == 0)
+ appends = NULL;
+ else if ((appends = malloc(sizeof(struct s_appends) * appendnum)) ==
+ NULL)
err(1, "malloc");
if ((match = malloc((maxnsub + 1) * sizeof(regmatch_t))) == NULL)
err(1, "malloc");
OpenPOWER on IntegriCloud