summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-12-11 17:45:41 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-16 06:22:18 +0200
commitd34257b5a3ec9d1b9884b68424573b14b9d131e9 (patch)
tree9fe8b15e6d0cf7f1d33d0522c3cfec6a12fc6900
parentde8ec24998b7cf3e8a9842db0c99af92c8a6475d (diff)
downloadmpv-d34257b5a3ec9d1b9884b68424573b14b9d131e9.tar.bz2
mpv-d34257b5a3ec9d1b9884b68424573b14b9d131e9.tar.xz
ad_speex: Fix possible memory leaks on error
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32689 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/ad_speex.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c
index f80b4d633e..a8d0bf4036 100644
--- a/libmpcodecs/ad_speex.c
+++ b/libmpcodecs/ad_speex.c
@@ -65,7 +65,7 @@ static int init(sh_audio_t *sh) {
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 @@ static int init(sh_audio_t *sh) {
}
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 @@ static int init(sh_audio_t *sh) {
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) {