Fix T40224: Crash moving objects to another layer

passing NULL to BLI_sprintfN crashed in some cases.
This commit is contained in:
Campbell Barton 2014-05-20 21:01:02 +10:00
parent 358664a28a
commit c998d6d4b5
Notes: blender-bot 2023-12-08 16:39:08 +01:00
Referenced by commit 9296f0c2fe, This reverts commit c998d6d4b5.
Referenced by issue #40224, Moving objects to another layer crashes Blender
1 changed files with 7 additions and 3 deletions

View File

@ -4548,7 +4548,8 @@ char *RNA_path_full_struct_py(struct PointerRNA *ptr)
char *RNA_path_full_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
{
char *id_path;
char *data_path;
const char *data_path_fallback = "(null)";
const char *data_path;
char *ret;
@ -4560,6 +4561,9 @@ char *RNA_path_full_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
id_path = RNA_path_full_ID_py(ptr->id.data);
data_path = RNA_path_from_ID_to_property(ptr, prop);
if (data_path == NULL) {
data_path = data_path_fallback;
}
if ((index == -1) || (RNA_property_array_check(prop) == false)) {
ret = BLI_sprintfN("%s.%s",
@ -4570,8 +4574,8 @@ char *RNA_path_full_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
id_path, data_path, index);
}
MEM_freeN(id_path);
if (data_path) {
MEM_freeN(data_path);
if (data_path != data_path_fallback) {
MEM_freeN((void *)data_path);
}
return ret;