modplug: avoid division by zero

Under some conditions, GetMaxPosition() returns zero, which should cause
position queries to fail rather than crash.
This commit is contained in:
Jonathan Matthew 2020-08-28 07:53:26 +10:00
parent 04fd705906
commit 2b024ec1b4

View file

@ -298,11 +298,15 @@ gst_modplug_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
gst_query_parse_position (query, &format, NULL); gst_query_parse_position (query, &format, NULL);
if (format == GST_FORMAT_TIME) { if (format == GST_FORMAT_TIME) {
gint64 pos; gint64 pos;
guint32 max;
pos = (modplug->song_length * modplug->mSoundFile->GetCurrentPos ()); max = modplug->mSoundFile->GetMaxPosition();
pos /= modplug->mSoundFile->GetMaxPosition (); if (max > 0) {
gst_query_set_position (query, format, pos); pos = (modplug->song_length * modplug->mSoundFile->GetCurrentPos ()) /
res = TRUE; max;
gst_query_set_position (query, format, pos);
res = TRUE;
}
} }
} }
break; break;