> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf > Of Linjie Fu > Sent: Monday, November 5, 2018 5:39 PM > To: ffmpeg-devel@ffmpeg.org > Cc: Fu, Linjie <linjie...@intel.com> > Subject: [FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the > initialization postion of profile_string > > 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 <linjie...@intel.com> > --- > 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); > +
Please don't introduce redundant line. > 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); > > -- > 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel