Skip to content

Commit 08e4c89

Browse files
bgiedsnopek
authored andcommitted
Fix buffer overrun with enums pointers cast to int64_t* when enum is only 32-bit
(cherry picked from commit 7576dc5)
1 parent 86d0dbe commit 08e4c89

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

binding_generator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,10 @@ def get_encoded_arg(arg_name, type_name, type_meta):
22242224
result.append(f"\t{get_gdextension_type(arg_type)} {name}_encoded;")
22252225
result.append(f"\tPtrToArg<{correct_type(type_name)}>::encode({name}, &{name}_encoded);")
22262226
name = f"&{name}_encoded"
2227+
elif is_enum(type_name) and not is_bitfield(type_name):
2228+
result.append(f"\tint64_t {name}_encoded;")
2229+
result.append(f"\tPtrToArg<int64_t>::encode({name}, &{name}_encoded);")
2230+
name = f"&{name}_encoded"
22272231
elif is_engine_class(type_name):
22282232
# `{name}` is a C++ wrapper, it contains a field which is the object's pointer Godot expects.
22292233
# We have to check `nullptr` because when the caller sends `nullptr`, the wrapper itself will be null.

0 commit comments

Comments
 (0)