From da8288eeee8ff625115008ddae759f369dcc1e24 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 11 Jun 2022 13:39:14 -0700 Subject: [PATCH] [Converter] Change utility function for safety Surprised I didn't catch this sooner. This could have resulted in a division by zero error if either sample rate somehow was zero. Signed-off-by: Christopher Snowhill --- Audio/ThirdParty/lvqcl/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Audio/ThirdParty/lvqcl/util.h b/Audio/ThirdParty/lvqcl/util.h index ec26088db..3a3ed3c48 100644 --- a/Audio/ThirdParty/lvqcl/util.h +++ b/Audio/ThirdParty/lvqcl/util.h @@ -42,7 +42,7 @@ static inline unsigned local_gcd(unsigned a, unsigned b) */ static void samples_len(unsigned* r1, unsigned* r2, unsigned N, unsigned M) // example: r1 = 44100, r2 = 48000, N = 20, M = 8192 { - if (r1 == 0 || r2 == 0) return; + if (r1 == 0 || r2 == 0 || *r1 == 0 || *r2 == 0) return; unsigned v = local_gcd(*r1, *r2); // v = 300 *r1 /= v; *r2 /= v; // r1 = 147; r2 = 160 == 1/300th of second unsigned n = (v + N-1) / N; // n = 300/20 = 15 times