From 378e49059ee1099c900b147ae6e760bca74e4e3d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Feb 2025 14:31:12 +1100 Subject: [PATCH] Fix invalid null checks (caught by cppcheck) Resolve two instances where values were null checked after use. --- .../editors/space_outliner/outliner_edit.cc | 14 ++++++++------ source/blender/io/ply/exporter/ply_file_buffer.cc | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index c314d147074..b433bf4c6eb 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -2040,12 +2040,14 @@ static void do_outliner_keyingset_editop(SpaceOutliner *space_outliner, /* check if RNA-property described by this selected element is an animatable prop */ const TreeElementRNACommon *te_rna = tree_element_cast(te); - PointerRNA ptr = te_rna->get_pointer_rna(); - if (te_rna && te_rna->get_property_rna() && - RNA_property_anim_editable(&ptr, te_rna->get_property_rna())) - { - /* get id + path + index info from the selected element */ - tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); + if (te_rna) { + PointerRNA ptr = te_rna->get_pointer_rna(); + if (PropertyRNA *prop = te_rna->get_property_rna()) { + if (RNA_property_anim_editable(&ptr, prop)) { + /* get id + path + index info from the selected element */ + tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); + } + } } /* only if ID and path were set, should we perform any actions */ diff --git a/source/blender/io/ply/exporter/ply_file_buffer.cc b/source/blender/io/ply/exporter/ply_file_buffer.cc index 7de1c0fb09d..68ab50f9ec8 100644 --- a/source/blender/io/ply/exporter/ply_file_buffer.cc +++ b/source/blender/io/ply/exporter/ply_file_buffer.cc @@ -37,11 +37,14 @@ void FileBuffer::write_to_file() void FileBuffer::close_file() { + if (!outfile_) { + return; + } int close_status = std::fclose(outfile_); if (close_status == EOF) { return; } - if (outfile_ && close_status) { + if (close_status) { CLOG_ERROR(&LOG, "Error: could not close file '%s' properly, it may be corrupted.", filepath_); } }