From ec6a855b3a6b87f3415cc4ecfc685bd2eefc6a80 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 6 Oct 2014 14:10:37 +0200 Subject: [PATCH] avcodec/vdpau: warn if the user application has not setup avctx->hwaccel_context instead of potentially crashing Signed-off-by: Michael Niedermayer --- libavcodec/vdpau.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 316281457e..f2b4acdb6d 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -83,6 +83,12 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, uint32_t width = (avctx->coded_width + 1) & ~1; uint32_t height = (avctx->coded_height + 3) & ~3; + if (!hwctx) { + vdctx->device = VDP_INVALID_HANDLE; + av_log(avctx, AV_LOG_WARNING, "hwaccel_context has not been setup by the user application, cannot initialize\n"); + return 0; + } + if (hwctx->context.decoder != VDP_INVALID_HANDLE) { vdctx->decoder = hwctx->context.decoder; vdctx->render = hwctx->context.render;