diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2022-06-07 15:01:46 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2022-06-07 15:01:46 +0300 |
commit | 1456f30b02548a9938aa6c3e07798b0aeedddc4b (patch) | |
tree | 9a46e90818bc041d46794068aa63b35e487f2c0c /source/blender/editors/gizmo_library | |
parent | 2918a3a2a374d9ad98923e9f6824534d7872c83f (diff) |
Cleanup: potential dereferencing of a NULL pointer
If `cancel` is `false`, `NULL` `inter` pointer dereferencing could occur.
Currently I haven't found a case where this can happen.
But it's best to avoid.
Diffstat (limited to 'source/blender/editors/gizmo_library')
-rw-r--r-- | source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c index 71db88419d5..fca51c264d3 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -539,10 +539,11 @@ static int gizmo_dial_modal(bContext *C, static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel) { DialInteraction *inter = gz->interaction_data; - bool use_reset_value = false; - float reset_value = 0.0f; - if (cancel) { - if (inter) { + if (inter) { + bool use_reset_value = false; + float reset_value = 0.0f; + + if (cancel) { /* Set the property for the operator and call its modal function. */ wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); if (WM_gizmo_target_property_is_valid(gz_prop)) { @@ -550,21 +551,21 @@ static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel) reset_value = inter->init.prop_angle; } } - } - else { - if (inter->has_drag == false) { - PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "click_value"); - if (RNA_property_is_set(gz->ptr, prop)) { - use_reset_value = true; - reset_value = RNA_property_float_get(gz->ptr, prop); + else { + if (inter->has_drag == false) { + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "click_value"); + if (RNA_property_is_set(gz->ptr, prop)) { + use_reset_value = true; + reset_value = RNA_property_float_get(gz->ptr, prop); + } } } - } - if (use_reset_value) { - wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); - if (WM_gizmo_target_property_is_valid(gz_prop)) { - WM_gizmo_target_property_float_set(C, gz, gz_prop, reset_value); + if (use_reset_value) { + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_float_set(C, gz, gz_prop, reset_value); + } } } |