From patchwork Mon Nov 5 09:39:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 10926 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 8FA2944C680 for ; Mon, 5 Nov 2018 11:39:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ECC9068A89D; Mon, 5 Nov 2018 11:39:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4C28068A816 for ; Mon, 5 Nov 2018 11:38:56 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2018 01:39:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,467,1534834800"; d="scan'208";a="97693233" Received: from kubernetes-master.sh.intel.com ([10.239.159.155]) by orsmga003.jf.intel.com with ESMTP; 05 Nov 2018 01:39:27 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Nov 2018 17:39:23 +0800 Message-Id: <20181105093923.32626-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the initialization postion of profile_string 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" Currently, profile_string was initialized in the "for" loop. If it didn't enter this loop or accidently break, profile_string may be uninitialized. Modify to initialize the profile_string after the loop to avoid using the uninitialized value when calling av_log. Signed-off-by: Linjie Fu --- libavcodec/vaapi_encode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2c34cdce2c..b43b52f0e5 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1066,6 +1066,7 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx) } av_assert0(ctx->codec->profiles); + for (i = 0; (ctx->codec->profiles[i].av_profile != FF_PROFILE_UNKNOWN); i++) { profile = &ctx->codec->profiles[i]; @@ -1080,12 +1081,6 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx) avctx->profile != FF_PROFILE_UNKNOWN) continue; -#if VA_CHECK_VERSION(1, 0, 0) - profile_string = vaProfileStr(profile->va_profile); -#else - profile_string = "(no profile names)"; -#endif - for (j = 0; j < n; j++) { if (va_profiles[j] == profile->va_profile) break; @@ -1107,6 +1102,11 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx) avctx->profile = profile->av_profile; ctx->va_profile = profile->va_profile; +#if VA_CHECK_VERSION(1, 0, 0) + profile_string = vaProfileStr(profile->va_profile); +#else + profile_string = "(no profile names)"; +#endif av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %s (%d).\n", profile_string, ctx->va_profile);