Skip to content

Commit c612798

Browse files
Sackzementslouken
authored andcommitted
Freeing memory on error
1 parent 59a2f77 commit c612798

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/decoder_opus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ static bool SDLCALL OPUS_init_audio(SDL_IOStream *io, SDL_AudioSpec *spec, SDL_P
151151
// now open the stream for serious processing.
152152
of = opus.op_open_callbacks(io, &OPUS_IoCallbacks, NULL, 0, &rc);
153153
if (!of) {
154+
SDL_free(adata);
154155
return set_op_error("ov_open_callbacks", rc);
155156
}
156157

157158
const OpusHead *info = opus.op_head(of, -1);
158159
if (!info) {
159160
opus.op_free(of);
161+
SDL_free(adata);
160162
return SDL_SetError("Couldn't get Opus info; corrupt data?");
161163
}
162164

src/decoder_stb_vorbis.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static bool SDLCALL STBVORBIS_init_audio(SDL_IOStream *io, SDL_AudioSpec *spec,
157157
int error = 0;
158158
stb_vorbis *vorbis = stb_vorbis_open_io(io, 0, &error, NULL);
159159
if (!vorbis) {
160+
SDL_free(adata);
160161
return SetStbVorbisError("stb_vorbis_open_memory", error);
161162
}
162163

src/decoder_vorbis.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@ static bool SDLCALL VORBIS_init_audio(SDL_IOStream *io, SDL_AudioSpec *spec, SDL
171171
// now open the stream for serious processing.
172172
const int rc = vorbis.ov_open_callbacks(io, &vf, NULL, 0, VORBIS_IoCallbacks);
173173
if (rc < 0) {
174+
SDL_free(adata);
174175
return SetOggVorbisError("ov_open_callbacks", rc);
175176
}
176177

177178
const vorbis_info *vi = vorbis.ov_info(&vf, -1);
178179
if (!vi) {
179180
vorbis.ov_clear(&vf);
181+
SDL_free(adata);
180182
return SDL_SetError("Couldn't get Ogg Vorbis info; corrupt data?");
181183
}
182184

0 commit comments

Comments
 (0)