dvdsubdec: Do not leak on failure path

CC: libav-stable@libav.org
Bug-Id: CID 1198262
(cherry picked from commit d466d82faa)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Luca Barbato 2014-11-09 08:48:47 +01:00
parent e9aeaa6441
commit 5891fd017a

View File

@ -503,6 +503,7 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
{ {
DVDSubContext *ctx = avctx->priv_data; DVDSubContext *ctx = avctx->priv_data;
char *data, *cur; char *data, *cur;
int ret = 0;
if (!avctx->extradata || !avctx->extradata_size) if (!avctx->extradata || !avctx->extradata_size)
return 0; return 0;
@ -527,16 +528,18 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
} else if (!strncmp("size:", cur, 5)) { } else if (!strncmp("size:", cur, 5)) {
int w, h; int w, h;
if (sscanf(cur + 5, "%dx%d", &w, &h) == 2) { if (sscanf(cur + 5, "%dx%d", &w, &h) == 2) {
int ret = ff_set_dimensions(avctx, w, h); ret = ff_set_dimensions(avctx, w, h);
if (ret < 0) if (ret < 0)
return ret; goto fail;
} }
} }
cur += strcspn(cur, "\n\r"); cur += strcspn(cur, "\n\r");
cur += strspn(cur, "\n\r"); cur += strspn(cur, "\n\r");
} }
fail:
av_free(data); av_free(data);
return 0; return ret;
} }
AVCodec ff_dvdsub_decoder = { AVCodec ff_dvdsub_decoder = {