stb_vorbis: Add missing error checks in comment reading mallocs
Backported from https://github.com/nothings/stb/pull/989. Fixes #40164.
This commit is contained in:
parent
624eff4633
commit
24a01c0d39
1 changed files with 3 additions and 0 deletions
3
thirdparty/misc/stb_vorbis.c
vendored
3
thirdparty/misc/stb_vorbis.c
vendored
|
@ -3630,6 +3630,7 @@ static int start_decoder(vorb *f)
|
|||
//file vendor
|
||||
len = get32_packet(f);
|
||||
f->vendor = (char*)setup_malloc(f, sizeof(char) * (len+1));
|
||||
if (f->vendor == NULL) return error(f, VORBIS_outofmem);
|
||||
for(i=0; i < len; ++i) {
|
||||
f->vendor[i] = get8_packet(f);
|
||||
}
|
||||
|
@ -3637,10 +3638,12 @@ static int start_decoder(vorb *f)
|
|||
//user comments
|
||||
f->comment_list_length = get32_packet(f);
|
||||
f->comment_list = (char**)setup_malloc(f, sizeof(char*) * (f->comment_list_length));
|
||||
if (f->comment_list == NULL) return error(f, VORBIS_outofmem);
|
||||
|
||||
for(i=0; i < f->comment_list_length; ++i) {
|
||||
len = get32_packet(f);
|
||||
f->comment_list[i] = (char*)setup_malloc(f, sizeof(char) * (len+1));
|
||||
if (f->comment_list[i] == NULL) return error(f, VORBIS_outofmem);
|
||||
|
||||
for(j=0; j < len; ++j) {
|
||||
f->comment_list[i][j] = get8_packet(f);
|
||||
|
|
Loading…
Reference in a new issue