Commit d550a285 authored by Alfred E. Heggestad's avatar Alfred E. Heggestad Committed by James Almer

dashenc: check pts to prevent division by zero error

this usecase will cause a division by zero trap:

1. dashenc has received one frame
2. os->max_pts and os->start_pts have same value
3. delta between max_pts and start_pts is 0
4. av_rescale_q(0, x, y) returns 0
5. this value is used as denominator in division
6. Bang! -> segfault

this fix checks that max_pts > start_pts.
the fix has been tested and works.
Signed-off-by: 's avatarAlfred E. Heggestad <alfred.heggestad@gmail.com>
Reviewed-by: 's avatarJeyapal, Karthick <kjeyapal@akamai.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 53b4128e
...@@ -1883,7 +1883,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream) ...@@ -1883,7 +1883,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
st->time_base, st->time_base,
AV_TIME_BASE_Q)); AV_TIME_BASE_Q));
if (!os->muxer_overhead) if (!os->muxer_overhead && os->max_pts > os->start_pts)
os->muxer_overhead = ((int64_t) (range_length - os->total_pkt_size) * os->muxer_overhead = ((int64_t) (range_length - os->total_pkt_size) *
8 * AV_TIME_BASE) / 8 * AV_TIME_BASE) /
av_rescale_q(os->max_pts - os->start_pts, av_rescale_q(os->max_pts - os->start_pts,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment