Fix (unreported) crash after new mapping node commit.

Blatant obvious usage of freed memory in rBbaaa89a0bc54.

And also fix a memleak in same code/commit...
This commit is contained in:
Bastien Montagne 2019-09-09 22:08:20 +02:00
parent c8c3e7d284
commit 3e81c1c1d5
Notes: blender-bot 2023-02-14 05:37:19 +01:00
Referenced by issue #70452, Crash when clicking "Solve Camera Motion" in Motion Tracking (2.81 nightly)
Referenced by issue #69711, Undo-related crash with custom Python operator
Referenced by issue #69708, Shift + double LMB click to smooth mask deactivates Dyntopo
Referenced by issue #68586, Crash when hiding collection that contains a disabled collection
1 changed files with 14 additions and 7 deletions

View File

@ -877,31 +877,38 @@ static void update_mapping_node_inputs_and_properties(bNodeTree *ntree)
AnimData *animData = BKE_animdata_from_id(&ntree->id);
if (animData && animData->action) {
const char *nodePath = BLI_sprintfN("nodes[\"%s\"]", node->name);
char *nodePath = BLI_sprintfN("nodes[\"%s\"]", node->name);
for (FCurve *fcu = animData->action->curves.first; fcu; fcu = fcu->next) {
if (STRPREFIX(fcu->rna_path, nodePath) &&
!BLI_str_endswith(fcu->rna_path, "default_value")) {
char *old_fcu_rna_path = fcu->rna_path;
MEM_freeN(fcu->rna_path);
if (BLI_str_endswith(fcu->rna_path, "translation")) {
if (BLI_str_endswith(old_fcu_rna_path, "translation")) {
fcu->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[1].default_value");
}
else if (BLI_str_endswith(fcu->rna_path, "rotation")) {
else if (BLI_str_endswith(old_fcu_rna_path, "rotation")) {
fcu->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[2].default_value");
}
else if (BLI_str_endswith(fcu->rna_path, "scale")) {
else if (BLI_str_endswith(old_fcu_rna_path, "scale")) {
fcu->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[3].default_value");
}
else if (minimumNode && BLI_str_endswith(fcu->rna_path, "min")) {
else if (minimumNode && BLI_str_endswith(old_fcu_rna_path, "min")) {
fcu->rna_path = BLI_sprintfN(
"nodes[\"%s\"].%s", minimumNode->name, "inputs[1].default_value");
}
else if (maximumNode && BLI_str_endswith(fcu->rna_path, "max")) {
else if (maximumNode && BLI_str_endswith(old_fcu_rna_path, "max")) {
fcu->rna_path = BLI_sprintfN(
"nodes[\"%s\"].%s", maximumNode->name, "inputs[1].default_value");
}
if (fcu->rna_path != old_fcu_rna_path) {
MEM_freeN(old_fcu_rna_path);
}
}
}
MEM_freeN(nodePath);
}
}
}