diff options
author | mikeh <mikeh@FreeBSD.org> | 2001-11-08 16:47:05 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2001-11-08 16:47:05 +0000 |
commit | 571866fa141cf4cc3865fb7f564c535aa2238ec6 (patch) | |
tree | 1bd88fc069c9dd6f70dbfb1dec34bba9d941952f /usr.bin/sed | |
parent | 3eabc457897905643fa5136789db9db5853f871c (diff) | |
download | FreeBSD-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')
-rw-r--r-- | usr.bin/sed/compile.c | 5 |
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"); |