Skip to content

Commit b86cf32

Browse files
authored
Merge pull request godotengine#1687 from bgie/enum_size
Fix buffer overrun with enums pointers cast to int64_t* when enum is only 32-bit
2 parents faf6fac + 7576dc5 commit b86cf32

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

0 commit comments

Comments
 (0)