From 02333fe394f0c15b1e8bbd3399316578ee8c2334 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 29 May 2019 10:57:18 +0200 Subject: avformat/gif: abort early if nothing was written yet Fixes crash when writting trailer without any previous packets. --- libavformat/gif.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libavformat') diff --git a/libavformat/gif.c b/libavformat/gif.c index 7916ba1e6b..e125d386bd 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -174,6 +174,9 @@ static int gif_write_trailer(AVFormatContext *s) GIFContext *gif = s->priv_data; AVIOContext *pb = s->pb; + if (!gif->prev_pkt) + return AVERROR(EINVAL); + gif_write_packet(s, NULL); if (!gif->have_end) -- cgit v1.2.3