summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-01 22:55:43 +0100
committerwm4 <wm4@nowhere>2015-11-01 23:03:02 +0100
commit1d2d649281ce4db792c40c2dd0ccf4b043a486f3 (patch)
tree9a65755f8bafa1d390257b6b7e7a2cb7def59b05 /video/decode
parent8e8b420c9d6428f57a422dbb6a27ff9c6c58dc3b (diff)
downloadmpv-1d2d649281ce4db792c40c2dd0ccf4b043a486f3.tar.bz2
mpv-1d2d649281ce4db792c40c2dd0ccf4b043a486f3.tar.xz
vdpau: fix uninit when init fails
The uninit() function was called twice if the uninit() function failed (once by init(), once by vd_lavc.c code), which caused crashes due to double-free. (This failure is a corner case, and all other hwdec backends appear to handle this case gracefully.) I do not think this code should be able to deal with uninit() being called other than once. Guarantee that it's called exactly once.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/vd_lavc.c1
-rw-r--r--video/decode/vdpau.c6
2 files changed, 2 insertions, 5 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index cdd0dd8884..9ce657bb5c 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -456,6 +456,7 @@ static void uninit_avctx(struct dec_video *vd)
if (ctx->hwdec && ctx->hwdec->uninit)
ctx->hwdec->uninit(ctx);
+ ctx->hwdec = NULL;
av_freep(&ctx->avctx);
diff --git a/video/decode/vdpau.c b/video/decode/vdpau.c
index 9a3e7e27cf..f8375532fb 100644
--- a/video/decode/vdpau.c
+++ b/video/decode/vdpau.c
@@ -80,13 +80,9 @@ static int init(struct lavc_ctx *ctx)
ctx->hwdec_priv = p;
if (mp_vdpau_handle_preemption(p->mpvdp, &p->preemption_counter) < 1)
- goto error;
+ return -1;
return 0;
-
-error:
- uninit(ctx);
- return -1;
}
static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,