diff options
author | Julian Eisel <julian@blender.org> | 2020-12-17 13:20:12 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-12-17 13:24:08 +0300 |
commit | 6203a3ee684d704f2270edde4df80e2549d1a38d (patch) | |
tree | 88eb6cb02c3133eaa86c645e04a9c6699c3cca35 /source/blender/editors/space_file | |
parent | 7e535499d5f691876a50aede97e52cbb07c3b636 (diff) |
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.
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 13 |
1 files changed, 11 insertions, 2 deletions
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; } |