[FFmpeg-cvslog] avformat/mpegts: Reset local nb_prg on add_program() failure

Michael Niedermayer git at videolan.org
Sun Apr 14 04:45:02 EEST 2024


ffmpeg | branch: release/6.1 | Michael Niedermayer <michael at niedermayer.cc> | Tue Feb 27 02:07:28 2024 +0100| [2da196b39a16e2c7244d61c04d9a123e1cb5a78e] | committer: Michael Niedermayer

avformat/mpegts: Reset local nb_prg on add_program() failure

add_program() will deallocate the whole array on failure so
we must clear nb_prgs

Fixes: null pointer dereference
Fixes: crash-35a3b39ddcc5babeeb005b7399a3a1217c8781bc

Found-by: Catena cyber
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit cb9752d897de17212a7a3ce54ad3e16b377b22c0)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/mpegts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 9babe68126..e70fe90f06 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2604,7 +2604,8 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
                     FFSWAP(struct Program, ts->prg[nb_prg], ts->prg[prg_idx]);
                 if (prg_idx >= nb_prg)
                     nb_prg++;
-            }
+            } else
+                nb_prg = 0;
         }
     }
     ts->nb_prg = nb_prg;



More information about the ffmpeg-cvslog mailing list