Fix #129159: Memory leak when node asset sockets have non-unique names
We weren't handling the failure case of `IDP_AddToGroup` when the property already exists. Arguably this is a bit bad because we're not recording the type of the second socket with the same name, but we don't really have the tools to solve that with IDProperties.
This commit is contained in:
@@ -1314,12 +1314,16 @@ void node_update_asset_metadata(bNodeTree &node_tree)
|
||||
auto outputs = idprop::create_group("outputs");
|
||||
node_tree.ensure_interface_cache();
|
||||
for (const bNodeTreeInterfaceSocket *socket : node_tree.interface_inputs()) {
|
||||
auto property = idprop::create(socket->name ? socket->name : "", socket->socket_type);
|
||||
IDP_AddToGroup(inputs.get(), property.release());
|
||||
auto prop = idprop::create(socket->name ? socket->name : "", socket->socket_type).release();
|
||||
if (!IDP_AddToGroup(inputs.get(), prop)) {
|
||||
IDP_FreeProperty(prop);
|
||||
}
|
||||
}
|
||||
for (const bNodeTreeInterfaceSocket *socket : node_tree.interface_outputs()) {
|
||||
auto property = idprop::create(socket->name ? socket->name : "", socket->socket_type);
|
||||
IDP_AddToGroup(outputs.get(), property.release());
|
||||
auto prop = idprop::create(socket->name ? socket->name : "", socket->socket_type).release();
|
||||
if (!IDP_AddToGroup(outputs.get(), prop)) {
|
||||
IDP_FreeProperty(prop);
|
||||
}
|
||||
}
|
||||
BKE_asset_metadata_idprop_ensure(asset_data, inputs.release());
|
||||
BKE_asset_metadata_idprop_ensure(asset_data, outputs.release());
|
||||
|
||||
Reference in New Issue
Block a user