[FFmpeg-cvslog] avformat/utils: avoid unsigned integer overflows

Paul B Mahol git at videolan.org
Sun Feb 16 14:06:15 EET 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Feb 15 14:52:47 2020 +0100| [96840e47de5199c258285d7b51f09d04ec0d1b72] | committer: Paul B Mahol

avformat/utils: avoid unsigned integer overflows

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96840e47de5199c258285d7b51f09d04ec0d1b72
---

 libavformat/utils.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7ff5ea9702..d5ad4ec4b0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4455,15 +4455,17 @@ void avformat_free_context(AVFormatContext *s)
     if (s->oformat && s->oformat->priv_class && s->priv_data)
         av_opt_free(s->priv_data);
 
-    for (i = s->nb_streams - 1; i >= 0; i--)
-        ff_free_stream(s, s->streams[i]);
-
+    for (i = 0; i < s->nb_streams; i++)
+        free_stream(&s->streams[i]);
+    s->nb_streams = 0;
 
-    for (i = s->nb_programs - 1; i >= 0; i--) {
+    for (i = 0; i < s->nb_programs; i++) {
         av_dict_free(&s->programs[i]->metadata);
         av_freep(&s->programs[i]->stream_index);
         av_freep(&s->programs[i]);
     }
+    s->nb_programs = 0;
+
     av_freep(&s->programs);
     av_freep(&s->priv_data);
     while (s->nb_chapters--) {



More information about the ffmpeg-cvslog mailing list