Allocating an array with zero entries is both unnecessary as well as potentially troublesome because the behaviour in this case is not really well defined.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavformat/nutenc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 6df7dfe210..5071278835 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -711,11 +711,15 @@ static int nut_write_header(AVFormatContext *s) } nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream )); - nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); nut->time_base= av_calloc(s->nb_streams + s->nb_chapters, sizeof(*nut->time_base)); - if (!nut->stream || !nut->chapter || !nut->time_base) + if (!nut->stream || !nut->time_base) return AVERROR(ENOMEM); + if (s->nb_chapters) { + nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); + if (!nut->chapter) + return AVERROR(ENOMEM); + } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".