Fix invalid memory handling in C++ OBJ MTL Importer.

An ID created with regualr ID management code should never ever be
directly freed directly.

For embedded nodetrees, there is a dedicated function.

Reviewed By: aras_p

Differential Revision: https://developer.blender.org/D15827
This commit is contained in:
Bastien Montagne 2022-09-01 09:16:15 +02:00 committed by Bastien Montagne
parent cdc0be48c9
commit 414baf9780
2 changed files with 6 additions and 4 deletions

View File

@ -143,6 +143,11 @@ static Image *load_texture_image(Main *bmain, const tex_map_XX &tex_map, bool re
return image;
}
void UniqueNodetreeDeleter::operator()(bNodeTree *node)
{
ntreeFreeEmbeddedTree(node);
}
ShaderNodetreeWrap::ShaderNodetreeWrap(Main *bmain,
const MTLMaterial &mtl_mat,
Material *mat,

View File

@ -22,10 +22,7 @@
namespace blender::io::obj {
struct UniqueNodetreeDeleter {
void operator()(bNodeTree *node)
{
MEM_freeN(node);
}
void operator()(bNodeTree *node);
};
using unique_nodetree_ptr = std::unique_ptr<bNodeTree, UniqueNodetreeDeleter>;