[FFmpeg-devel] [PATCH 1/2] avformat/utils: avoid unsigned integer overflows

Paul B Mahol onemda at gmail.com
Sat Feb 15 15:55:09 EET 2020


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavformat/utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 81ea239a66..ba2621aa28 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4450,10 +4450,12 @@ void avformat_free_context(AVFormatContext *s)
     if (s->oformat && s->oformat->priv_class && s->priv_data)
         av_opt_free(s->priv_data);
 
+    if (s->nb_streams)
     for (i = s->nb_streams - 1; i >= 0; i--)
         ff_free_stream(s, s->streams[i]);
 
 
+    if (s->nb_programs)
     for (i = s->nb_programs - 1; i >= 0; i--) {
         av_dict_free(&s->programs[i]->metadata);
         av_freep(&s->programs[i]->stream_index);
-- 
2.17.1



More information about the ffmpeg-devel mailing list