[Bf-blender-cvs] [1456f30b025] master: Cleanup: potential dereferencing of a NULL pointer

Germano Cavalcante noreply at git.blender.org
Tue Jun 7 14:12:59 CEST 2022


Commit: 1456f30b02548a9938aa6c3e07798b0aeedddc4b
Author: Germano Cavalcante
Date:   Tue Jun 7 09:01:46 2022 -0300
Branches: master
https://developer.blender.org/rB1456f30b02548a9938aa6c3e07798b0aeedddc4b

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.

===================================================================

M	source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c

===================================================================

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);
+      }
     }
   }



More information about the Bf-blender-cvs mailing list