godot-cpp
godot-cpp copied to clipboard
[GDNative] Godot::print and String() randomly change the input char*
Both the Godot::print(const char*) and String(const char*)-methods randomly change the content of their input const char*.
Here's a minimal reproduction method:
void SQLite::test(String input)
{
const CharString dummy_input = input.utf8();
const char *char_input = dummy_input.get_data();
std::cout << char_input << std::endl;
Godot::print(char_input);
std::cout << char_input << std::endl;
}
Code in Godot itself:
func _ready() -> void:
db = SQLite.new()
db.test("I love GDNative!")
Which prints in the console:
I love GDNative!
I love GDNative!
I love GDNative!
or
I love GDNative!
I love GDNative!
I
or
I love GDNative!
I love GDNative!
▐↕▬
or other similar random junk
Why is this happening? Am I not allowed to use char_input anymore after I print it?
Might be related? https://github.com/godotengine/godot/issues/40957