Skip to content

Commit

Permalink
music_ogg_stb.c: error-out early if the vorbis file has no samples
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero authored and icculus committed Dec 11, 2023
1 parent 47cff74 commit 44c50c7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/codecs/music_ogg_stb.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc)
}

rate = music->vi.sample_rate;

music->full_length = stb_vorbis_stream_length_in_samples(music->vf);
if (music->full_length <= 0) {
Mix_SetError("No samples in ogg/vorbis stream.");
OGG_Delete(music);
return NULL;
}

vc = stb_vorbis_get_comment(music->vf);
if (vc.comment_list != NULL) {
for (i = 0; i < vc.comment_list_length; i++) {
Expand Down Expand Up @@ -250,7 +258,6 @@ static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc)
}
}

music->full_length = stb_vorbis_stream_length_in_samples(music->vf);
if ((music->loop_end > 0) && (music->loop_end <= music->full_length) &&
(music->loop_start < music->loop_end)) {
music->loop = 1;
Expand Down

0 comments on commit 44c50c7

Please sign in to comment.