Page MenuHome

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

Authored by Bastien Montagne (mont29) on Aug 31 2022, 5:42 PM.

Details

Summary

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

For embedded nodetrees, there is a dedicated function.

Note: While this fix is not critical, since I don't think that code is
ever reached, would still add this to 3.3?

Diff Detail

Repository
rB Blender
Branch
tmp (branched from master)
Build Status
Buildable 23560
Build 23560: arc lint + arc unit

Event Timeline

Bastien Montagne (mont29) requested review of this revision.Aug 31 2022, 5:42 PM
Bastien Montagne (mont29) created this revision.

Looks good.

Overall this code indeed is probably unreachable; I got rid of most of unique_ptr things in the rest of OBJ importer (where it was even using them incorrectly to begin with), and my impression is that the unique_ptr usage in MTL importer part is also "a bit strange" - I don't quite see what advantages it brings, and is fairly confusing to read/understand.

This revision is now accepted and ready to land.Sep 1 2022, 6:07 AM

Looks good.

Overall this code indeed is probably unreachable; I got rid of most of unique_ptr things in the rest of OBJ importer (where it was even using them incorrectly to begin with), and my impression is that the unique_ptr usage in MTL importer part is also "a bit strange" - I don't quite see what advantages it brings, and is fairly confusing to read/understand.

Thanks.

Actually, I ran into this issue because I am working on changes related to T69169: Improve handling of embedded data-blocks (root nodetrees and master collections), which among other changes will result in the embedded node tree to be immediately assigned to its owner ID, removing any reason to use a unique_ptr here. So we should get rid of it hopefully soon in master. ;)