summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/compile.c
diff options
context:
space:
mode:
authormikeh <mikeh@FreeBSD.org>2001-11-08 16:47:05 +0000
committermikeh <mikeh@FreeBSD.org>2001-11-08 16:47:05 +0000
commit571866fa141cf4cc3865fb7f564c535aa2238ec6 (patch)
tree1bd88fc069c9dd6f70dbfb1dec34bba9d941952f /usr.bin/sed/compile.c
parent3eabc457897905643fa5136789db9db5853f871c (diff)
downloadFreeBSD-src-571866fa141cf4cc3865fb7f564c535aa2238ec6.zip
FreeBSD-src-571866fa141cf4cc3865fb7f564c535aa2238ec6.tar.gz
Don't allocate a zero byte segment.
PR: bin/11900 MFC after: 2 weeks
Diffstat (limited to 'usr.bin/sed/compile.c')
-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