[Bf-blender-cvs] [6203a3ee684] master: Fix T83878: Crash right-clicking in Asset Browser with no asset active

Julian Eisel noreply at git.blender.org
Thu Dec 17 11:24:20 CET 2020


Commit: 6203a3ee684d704f2270edde4df80e2549d1a38d
Author: Julian Eisel
Date:   Thu Dec 17 11:20:12 2020 +0100
Branches: master
https://developer.blender.org/rB6203a3ee684d704f2270edde4df80e2549d1a38d

Fix T83878: Crash right-clicking in Asset Browser with no asset active

Data of the File Browser context callback needs to be validated and
return `CTX_RESULT_NO_DATA` if the context member is valid but not set
in the current context.

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

M	source/blender/editors/space_file/space_file.c

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

diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 5bd7f6c17f6..774dc54700c 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -803,16 +803,25 @@ static int /*eContextResult*/ file_context(const bContext *C,
 
   if (CTX_data_equals(member, "active_file")) {
     FileDirEntry *file = filelist_file(sfile->files, params->active_file);
+    if (file == NULL) {
+      return CTX_RESULT_NO_DATA;
+    }
+
     CTX_data_pointer_set(result, &screen->id, &RNA_FileSelectEntry, file);
     return CTX_RESULT_OK;
   }
   if (CTX_data_equals(member, "id")) {
     const FileDirEntry *file = filelist_file(sfile->files, params->active_file);
+    if (file == NULL) {
+      return CTX_RESULT_NO_DATA;
+    }
 
     ID *id = filelist_file_get_id(file);
-    if (id) {
-      CTX_data_id_pointer_set(result, id);
+    if (id == NULL) {
+      return CTX_RESULT_NO_DATA;
     }
+
+    CTX_data_id_pointer_set(result, id);
     return CTX_RESULT_OK;
   }



More information about the Bf-blender-cvs mailing list