Fix dangling pointer in custom Reference _new#401
Closed
sheepandshepherd wants to merge 1 commit intogodotengine:masterfrom
Closed
Fix dangling pointer in custom Reference _new#401sheepandshepherd wants to merge 1 commit intogodotengine:masterfrom
sheepandshepherd wants to merge 1 commit intogodotengine:masterfrom
Conversation
3ff5947 to
6569bb4
Compare
Collaborator
|
@Zylann Is your PR an alternative to this or will this remain valid even after we apply your fix? |
Collaborator
|
@BastiaanOlij my fix solves the same problem without the side-effect, so I think it won't be needed anymore. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GODOT_CLASS's
_new()frees the pointer it's supposed to return:This PR inserts a
reference()after theNativeScript::new_()call.It does the same thing as #346, only at the location actually causing the dangling pointer, rather than in
NativeScript::new_(). That function already works correctly, returning with a ref-count of 1.Fixes #343 and #397
As discussed in #215, #346, and this comment, there's now a memory leak of the returned Reference because
Ref(T *)increases its ref-count to 2. Another fix such as #350 will be needed in addition to this.