Fix #117720: Crash when selecting these two armatures
Properly wrap a returned `char *` that could be `nullptr` into an `std::optional<std::string>`. `std::string` doesn't like `nullptr`. Another problem was that the wrapped `char *` was actually allocated on the heap, and not freed after conversion to a `std::string`, causing memory leaks.
This commit is contained in:
@@ -905,7 +905,16 @@ std::optional<std::string> RNA_path_from_struct_to_idproperty(PointerRNA *ptr,
|
||||
if (!haystack) { /* can fail when called on bones */
|
||||
return std::nullopt;
|
||||
}
|
||||
return rna_idp_path(ptr, haystack, needle, nullptr);
|
||||
|
||||
const char *path = rna_idp_path(ptr, haystack, needle, nullptr);
|
||||
if (!path) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string string_path(path);
|
||||
MEM_freeN((void *)path);
|
||||
|
||||
return string_path;
|
||||
}
|
||||
|
||||
static std::optional<std::string> rna_path_from_ID_to_idpgroup(const PointerRNA *ptr)
|
||||
|
||||
Reference in New Issue
Block a user