From d79638a1b6ff6563a82b57732ce05ca27cc54338 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 7 Nov 2023 22:40:04 +0300
Subject: [PATCH] Import an stb_vorbis fix from upstream PR/1563:
Patch by Seb de Graffenried (@Seb-degraff): https://github.com/nothings/stb/pull/1563
Fixes distorted decompressed audio when UBSan was enabled.
(cherry picked from commit c015a42bc0f7ec2ef61f5cc3fa18db9ea10e9fb9)
---
src/codecs/stb_vorbis/stb_vorbis.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/codecs/stb_vorbis/stb_vorbis.h b/src/codecs/stb_vorbis/stb_vorbis.h
index 7934e165..9e59df2c 100644
--- a/src/codecs/stb_vorbis/stb_vorbis.h
+++ b/src/codecs/stb_vorbis/stb_vorbis.h
@@ -2153,7 +2153,7 @@ STB_FORCEINLINE void draw_line(float *output, int x0, int y0, int x1, int y1, in
ady -= abs(base) * adx;
if (x1 > n) x1 = n;
if (x < x1) {
- LINE_OP(output[x], inverse_db_table[y&255]);
+ LINE_OP(output[x], inverse_db_table[(uint32)y&255]);
for (++x; x < x1; ++x) {
err += ady;
if (err >= adx) {
@@ -2161,7 +2161,7 @@ STB_FORCEINLINE void draw_line(float *output, int x0, int y0, int x1, int y1, in
y += sy;
} else
y += base;
- LINE_OP(output[x], inverse_db_table[y&255]);
+ LINE_OP(output[x], inverse_db_table[(uint32)y&255]);
}
}
}