Skip to content

Commit

Permalink
stb_vorbis: Add missing error checks in comment reading mallocs
Browse files Browse the repository at this point in the history
Fixes #988.
  • Loading branch information
akien-mga committed Jul 7, 2020
1 parent f54acd4 commit c24de24
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stb_vorbis.c
Expand Up @@ -31,7 +31,7 @@
// Phillip Bennefall Rohit Thiago Goulart
// github:manxorist saga musix github:infatum
// Timur Gagiev Maxwell Koo Peter Waller
// github:audinowho Dougall Johnson
// github:audinowho Dougall Johnson Rémi Verschelde
//
// Partial history:
// 1.19 - 2020-02-05 - warnings
Expand Down Expand Up @@ -3630,17 +3630,20 @@ 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);
}
f->vendor[len] = (char)'\0';
//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);
Expand Down

0 comments on commit c24de24

Please sign in to comment.