summaryrefslogtreecommitdiffstats
path: root/video/decode/vd_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-29 20:37:12 +0200
committerwm4 <wm4@nowhere>2014-09-29 20:37:12 +0200
commitc2592be4f0ee8ffa77e23295b167397554f5c418 (patch)
treef5a99a82ebbcda03d9104a2f7e2eb72edcea4198 /video/decode/vd_lavc.c
parent053196de84ea785bde70c3b544742a654191e258 (diff)
downloadmpv-c2592be4f0ee8ffa77e23295b167397554f5c418.tar.bz2
mpv-c2592be4f0ee8ffa77e23295b167397554f5c418.tar.xz
vd_lavc: fix a small memory leak on init error
The private context wasn't free'd when codec init failed. Restructure the code so that it can't happen.
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r--video/decode/vd_lavc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index b500bdb889..4de03e8af0 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -62,8 +62,6 @@ static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags);
static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
const enum AVPixelFormat *pix_fmt);
-static void uninit(struct dec_video *vd);
-
#define OPT_BASE_STRUCT struct vd_lavc_params
struct vd_lavc_params {
@@ -254,6 +252,11 @@ static struct vd_lavc_hwdec *probe_hwdec(struct dec_video *vd, bool autoprobe,
return NULL;
}
+static void uninit(struct dec_video *vd)
+{
+ uninit_avctx(vd);
+ talloc_free(vd->priv);
+}
static int init(struct dec_video *vd, const char *decoder)
{
@@ -439,11 +442,6 @@ static void uninit_avctx(struct dec_video *vd)
av_frame_free(&ctx->pic);
}
-static void uninit(struct dec_video *vd)
-{
- uninit_avctx(vd);
-}
-
static void update_image_params(struct dec_video *vd, AVFrame *frame,
struct mp_image_params *out_params)
{