-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Resource Importer use after free #84872
Conversation
I'm not familiar with this code, but the proposed solution seems unconventional. Both returning the pointer while keeping modifying it passed as argument in recursive calls seems like a recipe for disaster, or at least not knowing what one ends up with when reading that code. |
Sure. That makes sense. I'll give it another go. Was just looking for some feedback as the right direction to take. |
@lyuma You may be interested in looking at this. |
Reproduction steps.
Reproduction glb model (rename to .glb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I investigated the code without looking at this PR, and I ended up coming to the same conclusion as the OP. We need to return a pointer to the new node, because we are replacing the node. This PR is exactly what I'd do to fix the problem.
@akien-mga: Both returning the pointer while keeping modifying it passed as argument in recursive calls seems like a recipe for disaster, or at least not knowing what one ends up with when reading that code.
Well, it's not passed in recursive calls. The recursive calls have p_node
set to the previous call's p_node->get_child(i)
. Which are the same children as the original p_node
's children, because we are using replace_by
.
Once we run replace_by
, we are freeing the old node, so there is no purpose to having a reference to the old p_node
, so it makes perfect sense to me to overwrite that.
Thanks! |
Coverity reported issue.
If scene is a ImporterMeshInstance3D, it will be recreated which will leave the pointer (scene) in a bad state.
Testing with a single blend file, it appear not be this scenario. Only the child items appeared to be updated, so I'm not sure if this is the normal case for all import files.
These raise the questions
Found code just down from my change,
Should this be returning an error of some sort?