summaryrefslogtreecommitdiffstats
path: root/sub/lavc_conv.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-18 11:46:28 +0100
committerwm4 <wm4@nowhere>2016-01-18 11:46:28 +0100
commit0ed170ec0b7483568ad82c936afee7803a533908 (patch)
treedf2023695f49d775dfd6c2c22aa1b58b9d399562 /sub/lavc_conv.c
parent7b4ccb3e9f58a0745b58e473ee6e60b381242813 (diff)
downloadmpv-0ed170ec0b7483568ad82c936afee7803a533908.tar.bz2
mpv-0ed170ec0b7483568ad82c936afee7803a533908.tar.xz
sub: fix memory leaks
demux_lavf.c leaked the complete subtitle data if it was put through iconv. lavc_conv.c leaked AVCodecContext.subtitle_header (set by libavcodec), which is fixed by using avcodec_free_context(). It also leaked the subtitle that was decoded last.
Diffstat (limited to 'sub/lavc_conv.c')
-rw-r--r--sub/lavc_conv.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sub/lavc_conv.c b/sub/lavc_conv.c
index 42f9563391..f6c9b5abe2 100644
--- a/sub/lavc_conv.c
+++ b/sub/lavc_conv.c
@@ -78,7 +78,10 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name,
if (!avctx)
goto error;
avctx->extradata_size = extradata_len;
- avctx->extradata = talloc_memdup(priv, extradata, extradata_len);
+ avctx->extradata = av_malloc(extradata_len);
+ if (!avctx->extradata)
+ goto error;
+ memcpy(avctx->extradata, extradata, extradata_len);
if (avcodec_open2(avctx, codec, NULL) < 0)
goto error;
// Documented as "set by libavcodec", but there is no other way
@@ -264,7 +267,7 @@ void lavc_conv_reset(struct lavc_conv *priv)
void lavc_conv_uninit(struct lavc_conv *priv)
{
- avcodec_close(priv->avctx);
- av_free(priv->avctx);
+ avsubtitle_free(&priv->cur);
+ avcodec_free_context(&priv->avctx);
talloc_free(priv);
}