# HG changeset patch # User reimar # Date 1292089541 0 # Node ID 1cedf73225e041977b2d0c51d853fb83277d53c8 # Parent f23e289e35c67ebe8f6dc59fea3ca3062f57634f Fix possible memory leaks on error. diff -r f23e289e35c6 -r 1cedf73225e0 libmpcodecs/ad_speex.c --- a/libmpcodecs/ad_speex.c Sat Dec 11 16:36:17 2010 +0000 +++ b/libmpcodecs/ad_speex.c Sat Dec 11 17:45:41 2010 +0000 @@ -65,7 +65,7 @@ const SpeexStereoState st_st = SPEEX_STEREO_STATE_INIT; // hack if (!sh->wf || sh->wf->cbSize < 80) { mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Missing extradata!\n"); - return 0; + goto err_out; } ctx->hdr = speex_packet_to_header((char *)&sh->wf[1], sh->wf->cbSize); if (!ctx->hdr && sh->wf->cbSize == 0x72 && hdr[0] == 1 && hdr[1] == 0) { @@ -87,7 +87,7 @@ } if (!ctx->hdr) { mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Invalid extradata!\n"); - return 0; + goto err_out; } if (ctx->hdr->nb_channels != 1 && ctx->hdr->nb_channels != 2) { mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Invalid number of channels (%i), " @@ -119,6 +119,12 @@ sh->sample_format = AF_FORMAT_S16_NE; sh->context = ctx; return 1; + +err_out: + if (ctx) + free(ctx->hdr); + free(ctx); + return 0; } static void uninit(sh_audio_t *sh) {