From patchwork Tue Jan 21 08:42:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 17446 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CFFC7448ABD for ; Tue, 21 Jan 2020 10:43:26 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BC14168AE9B; Tue, 21 Jan 2020 10:43:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 68D0268AC45 for ; Tue, 21 Jan 2020 10:43:19 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2020 00:43:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,345,1574150400"; d="scan'208";a="215464892" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by orsmga007.jf.intel.com with ESMTP; 21 Jan 2020 00:43:16 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jan 2020 16:42:19 +0800 Message-Id: <1579596139-24901-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] lavc/qsvenc: add NULL pointer check for frame before use X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Null Frame would be sent to MSDK to flush the encoder, hence add a NULL check before using frame->interlaced_frame to prevent the potential crash, regardless of the return value of MFXVideoENCODE_EncodeFrameAsync(). Signed-off-by: Linjie Fu --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 9e41650..2dfe107 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1481,7 +1481,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, 0 : ff_qsv_print_error(avctx, ret, "Error during encoding"); } - if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame->interlaced_frame) + if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame && frame->interlaced_frame) print_interlace_msg(avctx, q); if (*sync) {