summaryrefslogtreecommitdiff
path: root/thirdparty/minimp3/minimp3.h
diff options
context:
space:
mode:
authorVincent <vinsteimes@gmail.com>2021-11-30 18:02:42 +0100
committerVincent <vinsteimes@gmail.com>2021-12-01 14:30:38 +0100
commit2d0068d1cb658d6b600fdc3f9ae02fe56338297c (patch)
tree3ff71c7e6c3d9c540b9a74a801f63a620dd2d326 /thirdparty/minimp3/minimp3.h
parent56f73a7e294972ddabbada46fc75f3f7ef8ca36f (diff)
Fix crash when loading an invalid mp3 file
Diffstat (limited to 'thirdparty/minimp3/minimp3.h')
-rw-r--r--thirdparty/minimp3/minimp3.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/thirdparty/minimp3/minimp3.h b/thirdparty/minimp3/minimp3.h
index 796cbc1f8e..3220ae1a85 100644
--- a/thirdparty/minimp3/minimp3.h
+++ b/thirdparty/minimp3/minimp3.h
@@ -881,12 +881,22 @@ static void L3_midside_stereo(float *left, int n)
int i = 0;
float *right = left + 576;
#if HAVE_SIMD
- if (have_simd()) for (; i < n - 3; i += 4)
+ if (have_simd())
{
- f4 vl = VLD(left + i);
- f4 vr = VLD(right + i);
- VSTORE(left + i, VADD(vl, vr));
- VSTORE(right + i, VSUB(vl, vr));
+ for (; i < n - 3; i += 4)
+ {
+ f4 vl = VLD(left + i);
+ f4 vr = VLD(right + i);
+ VSTORE(left + i, VADD(vl, vr));
+ VSTORE(right + i, VSUB(vl, vr));
+ }
+#ifdef __GNUC__
+ /* Workaround for spurious -Waggressive-loop-optimizations warning from gcc.
+ * For more info see: https://github.com/lieff/minimp3/issues/88
+ */
+ if (__builtin_constant_p(n % 4 == 0) && n % 4 == 0)
+ return;
+#endif
}
#endif /* HAVE_SIMD */
for (; i < n; i++)
@@ -1353,7 +1363,7 @@ static void mp3d_DCT_II(float *grbuf, int n)
} else
#endif /* HAVE_SIMD */
#ifdef MINIMP3_ONLY_SIMD
- {}
+ {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
#else /* MINIMP3_ONLY_SIMD */
for (; k < n; k++)
{
@@ -1583,7 +1593,7 @@ static void mp3d_synth(float *xl, mp3d_sample_t *dstl, int nch, float *lins)
} else
#endif /* HAVE_SIMD */
#ifdef MINIMP3_ONLY_SIMD
- {}
+ {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
#else /* MINIMP3_ONLY_SIMD */
for (i = 14; i >= 0; i--)
{