Fix T102238: double free when storing attribute on empty geometry

This commit is contained in:
Jacques Lucke 2022-11-07 11:42:26 +01:00
parent 186f16e84c
commit e031a45d60
Notes: blender-bot 2023-02-14 06:46:23 +01:00
Referenced by issue #102238, Geometry Node: Memory leak -> EXCEPTION_ACCESS_VIOLATION -> EXCEPTION_INT_DIVIDE_BY_ZERO.
Referenced by issue #101972, Regression: GN: Crashes when setting Spline Type from NURBS to Bezier in a row.
2 changed files with 2 additions and 4 deletions

View File

@ -247,11 +247,8 @@ static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attr
}
case AttributeInit::Type::MoveArray: {
void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
void *data = add_generic_custom_data_layer(
add_generic_custom_data_layer(
custom_data, data_type, CD_ASSIGN, source_data, domain_num, attribute_id);
if (source_data != nullptr && data == nullptr) {
MEM_freeN(source_data);
}
break;
}
}

View File

@ -2800,6 +2800,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
int flag = 0;
if (!typeInfo->defaultname && CustomData_has_layer(data, type)) {
MEM_SAFE_FREE(layerdata);
return &data->layers[CustomData_get_layer_index(data, type)];
}