diff options
author | Jonathan Matthew <jonathan@d14n.org> | 2020-08-28 07:53:26 +1000 |
---|---|---|
committer | Jonathan Matthew <jonathan@d14n.org> | 2020-08-28 08:10:04 +1000 |
commit | 2b024ec1b4cbed31678bbb8da3ef0f8145f9953e (patch) | |
tree | fc40e25c81342f91c2d3de2c3be51c04e011edf5 | |
parent | 04fd705906f4bd4cf1901001484e60c21e1b3139 (diff) | |
download | gstreamer-plugins-bad-2b024ec1b4cbed31678bbb8da3ef0f8145f9953e.tar.gz |
modplug: avoid division by zero
Under some conditions, GetMaxPosition() returns zero, which should cause
position queries to fail rather than crash.
-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 30c5952ab..af6de488b 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; |