mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
8e8b420c9d
commit
1d2d649281
|
@ -456,6 +456,7 @@ static void uninit_avctx(struct dec_video *vd)
|
||||||
|
|
||||||
if (ctx->hwdec && ctx->hwdec->uninit)
|
if (ctx->hwdec && ctx->hwdec->uninit)
|
||||||
ctx->hwdec->uninit(ctx);
|
ctx->hwdec->uninit(ctx);
|
||||||
|
ctx->hwdec = NULL;
|
||||||
|
|
||||||
av_freep(&ctx->avctx);
|
av_freep(&ctx->avctx);
|
||||||
|
|
||||||
|
|
|
@ -80,13 +80,9 @@ static int init(struct lavc_ctx *ctx)
|
||||||
ctx->hwdec_priv = p;
|
ctx->hwdec_priv = p;
|
||||||
|
|
||||||
if (mp_vdpau_handle_preemption(p->mpvdp, &p->preemption_counter) < 1)
|
if (mp_vdpau_handle_preemption(p->mpvdp, &p->preemption_counter) < 1)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
uninit(ctx);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
|
static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
|
||||||
|
|
Loading…
Reference in New Issue