]> git.sesse.net Git - mlt/commitdiff
mlt_consumer_start(): check return value from mlt_properties_get_int()
authorMikko Rapeli <mikko.rapeli@iki.fi>
Tue, 24 Jul 2012 17:55:47 +0000 (19:55 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Tue, 24 Jul 2012 18:00:19 +0000 (20:00 +0200)
Fixes Coverity CID 709343: Division or modulo by zero (DIVIDE_BY_ZERO)
Division by expression "mlt_properties_get_int(properties, "frame_rate_num")" which may be zero has undefined behavior
On this path, function call "mlt_properties_get_int(properties, "frame_rate_num")" has return value of 0
 442        int frame_duration = 1000000 / mlt_properties_get_int( properties, "frame_rate_num" ) *
 443                        mlt_properties_get_int( properties, "frame_rate_den" );

src/framework/mlt_consumer.c

index 5ce25328eab4ee5dbca382c3756e099ee6072c60..5334e94384af621e0efb35e34b7fd69d67fb6102 100644 (file)
@@ -448,8 +448,15 @@ int mlt_consumer_start( mlt_consumer self )
        }
 
        // Set the frame duration in microseconds for the frame-dropping heuristic
-       int frame_duration = 1000000 / mlt_properties_get_int( properties, "frame_rate_num" ) *
-                       mlt_properties_get_int( properties, "frame_rate_den" );
+       int frame_rate_num = mlt_properties_get_int( properties, "frame_rate_num" );
+       int frame_rate_den = mlt_properties_get_int( properties, "frame_rate_den" );
+       int frame_duration = 0;
+
+       if ( frame_rate_num && frame_rate_den )
+       {
+               frame_duration = 1000000 / frame_rate_num * frame_rate_den;
+       }
+
        mlt_properties_set_int( properties, "frame_duration", frame_duration );
 
        // Check and run an ante command