From fda45f4537b82ee4566e475367c78935da8cdc90 Mon Sep 17 00:00:00 2001 From: Hui Jin Date: Fri, 26 Jul 2019 13:28:00 +0800 Subject: [PATCH] vo_d3d11/context: fix crash due to ctx->ra is null pointer access 'ctx->ra' is null pointer when d3d11 init failed before call 'ra_d3d11_create' in 'd3d11_init'. --- video/out/d3d11/context.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index 82c7d162f7..3b0ab49812 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -161,14 +161,16 @@ static void d3d11_uninit(struct ra_ctx *ctx) { struct priv *p = ctx->priv; - ra_tex_free(ctx->ra, &p->backbuffer); + if (ctx->ra) + ra_tex_free(ctx->ra, &p->backbuffer); SAFE_RELEASE(p->swapchain); vo_w32_uninit(ctx->vo); SAFE_RELEASE(p->device); // Destory the RA last to prevent objects we hold from showing up in D3D's // leak checker - ctx->ra->fns->destroy(ctx->ra); + if (ctx->ra) + ctx->ra->fns->destroy(ctx->ra); } static const struct ra_swapchain_fns d3d11_swapchain = {