Fix stb_vorbis bug with empty comment list files;

This commit is contained in:
bjorn 2021-03-18 12:43:36 -06:00
parent 0bb556554d
commit e008dd2323
1 changed files with 18 additions and 12 deletions

View File

@ -3299,6 +3299,7 @@ static int start_decoder(vorb *f)
f->vendor[len] = (char)'\0';
//user comments
f->comment_list_length = get32_packet(f);
if (f->comment_list_length > 0) {
f->comment_list = (char**)setup_malloc(f, sizeof(char*) * (f->comment_list_length));
if (f->comment_list == NULL) return error(f, VORBIS_outofmem);
@ -3312,6 +3313,9 @@ static int start_decoder(vorb *f)
}
f->comment_list[i][len] = (char)'\0';
}
} else {
f->comment_list = NULL;
}
// framing_flag
x = get8_packet(f);
@ -3848,10 +3852,12 @@ static void vorbis_deinit(stb_vorbis *p)
int i,j;
setup_free(p, p->vendor);
if (p->comment_list) {
for (i=0; i < p->comment_list_length; ++i) {
setup_free(p, p->comment_list[i]);
}
setup_free(p, p->comment_list);
}
if (p->residue_config) {
for (i=0; i < p->residue_count; ++i) {