Commit d7c05794 authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Fix possible division by zero in mkv and flv muxers on close

This could crash if anything failed before output.set_param (for example, incorrect params refused by x264_encoder_open).
Bug introduced in r1873.
parent 8c881320
......@@ -310,7 +310,7 @@ static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest
double total_duration = (2 * largest_pts - second_largest_pts) * p_flv->d_timebase;
if( x264_is_regular_file( c->fp ) )
if( x264_is_regular_file( c->fp ) && total_duration > 0 )
{
double framerate;
uint64_t filesize = ftell( c->fp );
......
......@@ -202,7 +202,7 @@ static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest
int ret;
int64_t i_last_delta;
i_last_delta = (int64_t)(((largest_pts - second_largest_pts) * p_mkv->i_timebase_num / p_mkv->i_timebase_den) + 0.5);
i_last_delta = p_mkv->i_timebase_den ? (int64_t)(((largest_pts - second_largest_pts) * p_mkv->i_timebase_num / p_mkv->i_timebase_den) + 0.5) : 0;
ret = mk_close( p_mkv->w, i_last_delta );
......
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