Skip to content

Do not clear variant on assignment to self#1960

Merged
dsnopek merged 1 commit intogodotengine:masterfrom
Naros:GH-1959
Mar 30, 2026
Merged

Do not clear variant on assignment to self#1960
dsnopek merged 1 commit intogodotengine:masterfrom
Naros:GH-1959

Conversation

@Naros
Copy link
Copy Markdown
Contributor

@Naros Naros commented Mar 29, 2026

Fixes #1959

As outlined in the issue, when working with an array of Variants, and you assign from one pointer to another, where both refer to the same memory location, the godot-cpp implementation of Variant::operator= clears the memory location, which yields the value after the assignment to be <null> due to the explicit call to clear().

The engine, on the other hand, guards against this corner case and skips the assignment.

@Naros Naros requested a review from a team as a code owner March 29, 2026 11:37
@Ivorforce Ivorforce added the bug This has been identified as a bug label Mar 30, 2026
Copy link
Copy Markdown
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me

@dsnopek dsnopek added this to the 10.x milestone Mar 30, 2026
@dsnopek dsnopek merged commit a3f5035 into godotengine:master Mar 30, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug cherrypick:4.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variant assignment can lead to null value

3 participants