mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 05:26:23 +00:00
utils: avoid dividing by zero when multiplying y/z by 0/x
The gcd of 0/x is 0, and this is then used as a denominator.
This commit is contained in:
parent
414f21d160
commit
3004cc5f45
1 changed files with 7 additions and 0 deletions
|
@ -3422,6 +3422,13 @@ gst_util_fraction_multiply (gint a_n, gint a_d, gint b_n, gint b_d,
|
|||
g_return_val_if_fail (a_d != 0, FALSE);
|
||||
g_return_val_if_fail (b_d != 0, FALSE);
|
||||
|
||||
/* early out if either is 0, as its gcd would be 0 */
|
||||
if (a_n == 0 || b_n == 0) {
|
||||
*res_n = 0;
|
||||
*res_d = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gcd = gst_util_greatest_common_divisor (a_n, a_d);
|
||||
a_n /= gcd;
|
||||
a_d /= gcd;
|
||||
|
|
Loading…
Reference in a new issue