diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-09-09 21:25:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 21:25:37 +0200 |
commit | 7015c59e2eb3979ac015e26af6e983fb83867ff6 (patch) | |
tree | b9c2258fd25902a2b9934af202c4d57b4321154e /modules | |
parent | 1ce46f2a3f81e2395767a693b773adce7758d048 (diff) | |
parent | d16f5a57c1882da245032b4543dbeb6d02931dbf (diff) |
Merge pull request #41921 from akien-mga/stb_vorbis-increase-max-alloc
stb_vorbis: Increase max alloc buffer size for big Vorbis comments
Diffstat (limited to 'modules')
-rw-r--r-- | modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 3aceaf11c5..346833ab9c 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -158,14 +158,16 @@ void AudioStreamOGGVorbis::clear_data() { void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) { int src_data_len = p_data.size(); -#define MAX_TEST_MEM (1 << 20) - uint32_t alloc_try = 1024; Vector<char> alloc_mem; char *w; stb_vorbis *ogg_stream = nullptr; stb_vorbis_alloc ogg_alloc; + // Vorbis comments may be up to UINT32_MAX, but that's arguably pretty rare. + // Let's go with 2^30 so we don't risk going out of bounds. + const uint32_t MAX_TEST_MEM = 1 << 30; + while (alloc_try < MAX_TEST_MEM) { alloc_mem.resize(alloc_try); w = alloc_mem.ptrw(); @@ -205,6 +207,8 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) { break; } } + + ERR_FAIL_COND_MSG(alloc_try == MAX_TEST_MEM, vformat("Couldn't set vorbis data even with an alloc buffer of %d bytes, report bug.", MAX_TEST_MEM)); } Vector<uint8_t> AudioStreamOGGVorbis::get_data() const { |