From: Jonathan Matthew Date: Thu, 27 Aug 2020 21:53:26 +0000 (+1000) Subject: modplug: avoid division by zero X-Git-Tag: 1.19.3~507^2~1444 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b024ec1b4cbed31678bbb8da3ef0f8145f9953e;p=platform%2Fupstream%2Fgstreamer.git modplug: avoid division by zero Under some conditions, GetMaxPosition() returns zero, which should cause position queries to fail rather than crash. --- diff --git a/ext/modplug/gstmodplug.cc b/ext/modplug/gstmodplug.cc index 30c5952..af6de48 100644 --- a/ext/modplug/gstmodplug.cc +++ b/ext/modplug/gstmodplug.cc @@ -298,11 +298,15 @@ gst_modplug_src_query (GstPad * pad, GstObject * parent, GstQuery * query) gst_query_parse_position (query, &format, NULL); if (format == GST_FORMAT_TIME) { gint64 pos; - - pos = (modplug->song_length * modplug->mSoundFile->GetCurrentPos ()); - pos /= modplug->mSoundFile->GetMaxPosition (); - gst_query_set_position (query, format, pos); - res = TRUE; + guint32 max; + + max = modplug->mSoundFile->GetMaxPosition(); + if (max > 0) { + pos = (modplug->song_length * modplug->mSoundFile->GetCurrentPos ()) / + max; + gst_query_set_position (query, format, pos); + res = TRUE; + } } } break;