]> git.sesse.net Git - mlt/commitdiff
qimage/kdenlivetitle_wrapper.cpp: check for division by zero
authorMikko Rapeli <mikko.rapeli@iki.fi>
Tue, 31 Jul 2012 09:59:17 +0000 (11:59 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Mon, 6 Aug 2012 16:37:27 +0000 (18:37 +0200)
Fixes Coverity CID 709345: Division or modulo by zero (DIVIDE_BY_ZERO)
Assigning: "anim_out" = "mlt_properties_get_position(producer_props, "_animation_out")".
On this path, function call "mlt_properties_get_position(producer_props, "_animation_out")" has return value of 0
465                mlt_position anim_out = mlt_properties_get_position( producer_props, "_animation_out" );
...
Division by expression "anim_out" which may be zero has undefined behavior
475                        double percentage = position / anim_out;

src/modules/qimage/kdenlivetitle_wrapper.cpp

index f12a8e71bfcb2f547cb848eb74bd3a0f08434a87..54469905ad0beadba8eb20fbec94da9ca98c137a 100755 (executable)
@@ -472,7 +472,9 @@ void drawKdenliveTitle( producer_ktitle self, mlt_frame frame, int width, int he
                         scene->render( &p1, source, end, Qt::IgnoreAspectRatio );
                 }
                else {
-                        double percentage = position / anim_out;
+                        double percentage = 0;
+                       if ( position && anim_out )
+                               percentage = position / anim_out;
                        QPointF topleft = start.topLeft() + ( end.topLeft() - start.topLeft() ) * percentage;
                        QPointF bottomRight = start.bottomRight() + ( end.bottomRight() - start.bottomRight() ) * percentage;
                        const QRectF r1( topleft, bottomRight );