Fix buffer overrun with enums pointers cast to int64_t* when enum is only 32-bit

pull/1687/head
Brecht Kuppens 2025-01-20 10:15:47 +01:00
parent befe3ee2f2
commit 7576dc5930
1 changed files with 4 additions and 0 deletions

View File

@ -2350,6 +2350,10 @@ def get_encoded_arg(arg_name, type_name, type_meta):
result.append(f"\t{get_gdextension_type(arg_type)} {name}_encoded;") result.append(f"\t{get_gdextension_type(arg_type)} {name}_encoded;")
result.append(f"\tPtrToArg<{correct_type(type_name)}>::encode({name}, &{name}_encoded);") result.append(f"\tPtrToArg<{correct_type(type_name)}>::encode({name}, &{name}_encoded);")
name = f"&{name}_encoded" name = f"&{name}_encoded"
elif is_enum(type_name) and not is_bitfield(type_name):
result.append(f"\tint64_t {name}_encoded;")
result.append(f"\tPtrToArg<int64_t>::encode({name}, &{name}_encoded);")
name = f"&{name}_encoded"
elif is_engine_class(type_name): elif is_engine_class(type_name):
# `{name}` is a C++ wrapper, it contains a field which is the object's pointer Godot expects. # `{name}` is a C++ wrapper, it contains a field which is the object's pointer Godot expects.
# We have to check `nullptr` because when the caller sends `nullptr`, the wrapper itself will be null. # We have to check `nullptr` because when the caller sends `nullptr`, the wrapper itself will be null.