Skip to content

Commit

Permalink
stb_vorbis: Fixed memory leak due to incorrect fix in nothings#1558. …
Browse files Browse the repository at this point in the history
…Thanks to sezero: nothings#1557 (comment)
  • Loading branch information
NBickford-NV committed Feb 17, 2024
1 parent 89311cf commit f3869f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stb_vorbis.c
Original file line number Diff line number Diff line change
Expand Up @@ -3694,15 +3694,18 @@ static int start_decoder(vorb *f)
return error(f, VORBIS_outofmem);
}
f->comment_list = (char**) setup_malloc(f, sizeof(char*) * (f->comment_list_length));
if (f->comment_list == NULL) return error(f, VORBIS_outofmem);
if (f->comment_list == NULL)
{
f->comment_list_length = 0;
return error(f, VORBIS_outofmem);
}
memset(f->comment_list, 0, sizeof(char*) * f->comment_list_length);
}

for(i=0; i < f->comment_list_length; ++i) {
len = get32_packet(f);
f->comment_list[i] = (INT_MAX == len) ? NULL : (char*)setup_malloc(f, sizeof(char) * (len+1));
if (f->comment_list[i] == NULL) {
f->comment_list_length = 0;
return error(f, VORBIS_outofmem);
}

Expand Down

0 comments on commit f3869f8

Please sign in to comment.