Fix crash when loading an invalid mp3 file
(cherry picked from commit 2d0068d1cb
)
This commit is contained in:
parent
2b9a1e0d2c
commit
72709bb821
|
@ -161,7 +161,7 @@ void AudioStreamMP3::set_data(const PoolVector<uint8_t> &p_data) {
|
||||||
|
|
||||||
mp3dec_ex_t mp3d;
|
mp3dec_ex_t mp3d;
|
||||||
int err = mp3dec_ex_open_buf(&mp3d, src_datar.ptr(), src_data_len, MP3D_SEEK_TO_SAMPLE);
|
int err = mp3dec_ex_open_buf(&mp3d, src_datar.ptr(), src_data_len, MP3D_SEEK_TO_SAMPLE);
|
||||||
ERR_FAIL_COND(err != 0);
|
ERR_FAIL_COND_MSG(err || mp3d.info.hz == 0, "Failed to decode mp3 file. Make sure it is a valid mp3 audio file.");
|
||||||
|
|
||||||
channels = mp3d.info.channels;
|
channels = mp3d.info.channels;
|
||||||
sample_rate = mp3d.info.hz;
|
sample_rate = mp3d.info.hz;
|
||||||
|
|
|
@ -284,6 +284,19 @@ File extracted from upstream release tarball:
|
||||||
providing configuration for light bundling with core.
|
providing configuration for light bundling with core.
|
||||||
|
|
||||||
|
|
||||||
|
## minimp3
|
||||||
|
|
||||||
|
- Upstream: https://github.com/lieff/minimp3
|
||||||
|
- Version: git (afb604c06bc8beb145fecd42c0ceb5bda8795144, 2021)
|
||||||
|
- License: CC0 1.0
|
||||||
|
|
||||||
|
Files extracted from upstream repository:
|
||||||
|
|
||||||
|
- `minimp3.h`
|
||||||
|
- `minimp3_ex.h`
|
||||||
|
- `LICENSE`
|
||||||
|
|
||||||
|
|
||||||
## miniupnpc
|
## miniupnpc
|
||||||
|
|
||||||
- Upstream: https://github.com/miniupnp/miniupnp
|
- Upstream: https://github.com/miniupnp/miniupnp
|
||||||
|
|
|
@ -881,12 +881,22 @@ static void L3_midside_stereo(float *left, int n)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
float *right = left + 576;
|
float *right = left + 576;
|
||||||
#if HAVE_SIMD
|
#if HAVE_SIMD
|
||||||
if (have_simd()) for (; i < n - 3; i += 4)
|
if (have_simd())
|
||||||
{
|
{
|
||||||
f4 vl = VLD(left + i);
|
for (; i < n - 3; i += 4)
|
||||||
f4 vr = VLD(right + i);
|
{
|
||||||
VSTORE(left + i, VADD(vl, vr));
|
f4 vl = VLD(left + i);
|
||||||
VSTORE(right + i, VSUB(vl, vr));
|
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 */
|
#endif /* HAVE_SIMD */
|
||||||
for (; i < n; i++)
|
for (; i < n; i++)
|
||||||
|
@ -1353,7 +1363,7 @@ static void mp3d_DCT_II(float *grbuf, int n)
|
||||||
} else
|
} else
|
||||||
#endif /* HAVE_SIMD */
|
#endif /* HAVE_SIMD */
|
||||||
#ifdef MINIMP3_ONLY_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 */
|
#else /* MINIMP3_ONLY_SIMD */
|
||||||
for (; k < n; k++)
|
for (; k < n; k++)
|
||||||
{
|
{
|
||||||
|
@ -1583,7 +1593,7 @@ static void mp3d_synth(float *xl, mp3d_sample_t *dstl, int nch, float *lins)
|
||||||
} else
|
} else
|
||||||
#endif /* HAVE_SIMD */
|
#endif /* HAVE_SIMD */
|
||||||
#ifdef MINIMP3_ONLY_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 */
|
#else /* MINIMP3_ONLY_SIMD */
|
||||||
for (i = 14; i >= 0; i--)
|
for (i = 14; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
This software is distributed without any warranty.
|
This software is distributed without any warranty.
|
||||||
See <http://creativecommons.org/publicdomain/zero/1.0/>.
|
See <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
*/
|
*/
|
||||||
|
#include <stddef.h>
|
||||||
#include "minimp3.h"
|
#include "minimp3.h"
|
||||||
|
|
||||||
/* flags for mp3dec_ex_open_* functions */
|
/* flags for mp3dec_ex_open_* functions */
|
||||||
|
@ -128,8 +129,10 @@ int mp3dec_ex_open_w(mp3dec_ex_t *dec, const wchar_t *file_name, int flags);
|
||||||
#endif
|
#endif
|
||||||
#endif /*MINIMP3_EXT_H*/
|
#endif /*MINIMP3_EXT_H*/
|
||||||
|
|
||||||
#ifdef MINIMP3_IMPLEMENTATION
|
#if defined(MINIMP3_IMPLEMENTATION) && !defined(_MINIMP3_EX_IMPLEMENTATION_GUARD)
|
||||||
|
#define _MINIMP3_EX_IMPLEMENTATION_GUARD
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include "minimp3.h"
|
||||||
|
|
||||||
static void mp3dec_skip_id3v1(const uint8_t *buf, size_t *pbuf_size)
|
static void mp3dec_skip_id3v1(const uint8_t *buf, size_t *pbuf_size)
|
||||||
{
|
{
|
||||||
|
@ -1391,4 +1394,4 @@ void mp3dec_ex_close(mp3dec_ex_t *dec)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*MINIMP3_IMPLEMENTATION*/
|
#endif /* MINIMP3_IMPLEMENTATION && !_MINIMP3_EX_IMPLEMENTATION_GUARD */
|
||||||
|
|
Loading…
Reference in New Issue