diff mbox series

[FFmpeg-devel] libavformat/dashenc.c: In some circumstances a total_duration equals to zero so that it makes possible for SIGFPE to appear and crash an application.

Message ID 20210217191213.197994-1-yashin.sergey@gmail.com
State New
Headers show
Series [FFmpeg-devel] libavformat/dashenc.c: In some circumstances a total_duration equals to zero so that it makes possible for SIGFPE to appear and crash an application.
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Sergei Iashin Feb. 17, 2021, 7:12 p.m. UTC
---
 libavformat/dashenc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 2d757b3a87..fbdee126e9 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -844,7 +844,11 @@  static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind
         if (os->bit_rate > 0)
             snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", os->bit_rate);
         else if (final) {
-            int average_bit_rate = os->pos * 8 * AV_TIME_BASE / c->total_duration;
+            int average_bit_rate = 0;
+            if(c->total_duration > 0)
+            {
+                average_bit_rate = os->pos * 8 * AV_TIME_BASE / c->total_duration;
+            }
             snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", average_bit_rate);
         } else if (os->first_segment_bit_rate > 0)
             snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", os->first_segment_bit_rate);