From 12f9ba5f372f098b4a49074940c2ad7dfcacf54b Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 19 Jan 2021 11:22:52 -0800 Subject: [PATCH] Guard against nullptr deref after AST-reduction consistency checks Addresses Coverity issue 1443771 --- src/script_opt/ScriptOpt.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index 12809d7ce9..c5b111d4ca 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -56,9 +56,16 @@ void optimize_func(ScriptFunc* f, ProfileFunc* pf, ScopePtr scope_ptr, non_reduced_perp = nullptr; checking_reduction = true; + if ( ! new_body->IsReduced(rc) ) - printf("Reduction inconsistency for %s: %s\n", f->Name(), - obj_desc(non_reduced_perp).c_str()); + { + if ( non_reduced_perp ) + printf("Reduction inconsistency for %s: %s\n", f->Name(), + obj_desc(non_reduced_perp).c_str()); + else + printf("Reduction inconsistency for %s\n", f->Name()); + } + checking_reduction = false; if ( analysis_options.only_func || analysis_options.dump_xform )