[Bf-blender-cvs] [e7274dedc44] master: Fix possible NULL pointer deference

Campbell Barton noreply at git.blender.org
Mon Oct 4 04:19:36 CEST 2021


Commit: e7274dedc4475e15cd06a7c83ec9e0d477f13314
Author: Campbell Barton
Date:   Mon Oct 4 13:12:34 2021 +1100
Branches: master
https://developer.blender.org/rBe7274dedc4475e15cd06a7c83ec9e0d477f13314

Fix possible NULL pointer deference

The pointer was referenced before being checked.

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

M	source/blender/editors/asset/intern/asset_library_reference_enum.cc

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

diff --git a/source/blender/editors/asset/intern/asset_library_reference_enum.cc b/source/blender/editors/asset/intern/asset_library_reference_enum.cc
index 5a8fed6fea1..c7c0f35c12d 100644
--- a/source/blender/editors/asset/intern/asset_library_reference_enum.cc
+++ b/source/blender/editors/asset/intern/asset_library_reference_enum.cc
@@ -80,14 +80,16 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
 
   /* Note that there is no check if the path exists here. If an invalid library path is used, the
    * Asset Browser can give a nice hint on what's wrong. */
-  const bool is_valid = (user_library->name[0] && user_library->path[0]);
   if (!user_library) {
     library.type = ASSET_LIBRARY_LOCAL;
     library.custom_library_index = -1;
   }
-  else if (user_library && is_valid) {
-    library.custom_library_index = value - ASSET_LIBRARY_CUSTOM;
-    library.type = ASSET_LIBRARY_CUSTOM;
+  else {
+    const bool is_valid = (user_library->name[0] && user_library->path[0]);
+    if (is_valid) {
+      library.custom_library_index = value - ASSET_LIBRARY_CUSTOM;
+      library.type = ASSET_LIBRARY_CUSTOM;
+    }
   }
   return library;
 }



More information about the Bf-blender-cvs mailing list