From f3b3af20300aed213c3692d05a676068b2350782 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 30 Jul 2020 07:43:28 +0200 Subject: [PATCH] ffmpeg/tools: Ensure we aren't comparing against a nullptr --- source/ffmpeg/tools.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/ffmpeg/tools.cpp b/source/ffmpeg/tools.cpp index 9a33a12..5905a2c 100644 --- a/source/ffmpeg/tools.cpp +++ b/source/ffmpeg/tools.cpp @@ -359,10 +359,12 @@ void tools::print_av_option_string2(AVCodecContext* ctx_codec, void* ctx_option, // Find the unit for the option. auto* unitopt = av_opt_find(ctx_option, option.data(), nullptr, 0, AV_OPT_SEARCH_CHILDREN); - if (unitopt) { + if (unitopt && unitopt->unit) { std::string_view optname; - for (auto* opt = unitopt; - (opt = av_opt_next(ctx_option, opt)) != nullptr && (strcmp(unitopt->unit, opt->unit) == 0);) { + for (auto* opt = unitopt; (opt = av_opt_next(ctx_option, opt)) != nullptr;) { + if (opt->unit && (strcmp(unitopt->unit, opt->unit) != 0)) + continue; + if (opt->default_val.i64 == v) optname = opt->name; }