Fix stb_vorbis bug with empty comment list files;
@@ -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) {
