diff options
author | Jonathan Matthew <jonathan@d14n.org> | 2020-08-28 07:53:26 +1000 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-09-25 14:46:18 +0000 |
commit | 61703cb350e687cf503f21e16b07d7ded4b325a7 (patch) | |
tree | e032fbb7c7bf2fbe8971b12e27beafeb92d2f0b5 | |
parent | 77d35ef696a3035af713c41df92faddd18178d7a (diff) | |
download | gstreamer-plugins-bad-61703cb350e687cf503f21e16b07d7ded4b325a7.tar.gz |
modplug: avoid division by zero
Under some conditions, GetMaxPosition() returns zero, which should cause
position queries to fail rather than crash.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1608>
-rw-r--r-- | ext/modplug/gstmodplug.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/modplug/gstmodplug.cc b/ext/modplug/gstmodplug.cc index b5fbcb252..3397fcc52 100644 --- a/ext/modplug/gstmodplug.cc +++ b/ext/modplug/gstmodplug.cc @@ -299,11 +299,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; |