Skip to content

Commit

Permalink
Fix crash in ClassDB::add_virtual_method() if arguments metadata is…
Browse files Browse the repository at this point in the history
… the wrong size
  • Loading branch information
dsnopek committed Oct 29, 2024
1 parent d477589 commit 1e169bb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,14 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
if (mi.argument_count > 0) {
mi.arguments = (GDExtensionPropertyInfo *)memalloc(sizeof(GDExtensionPropertyInfo) * mi.argument_count);
mi.arguments_metadata = (GDExtensionClassMethodArgumentMetadata *)memalloc(sizeof(GDExtensionClassMethodArgumentMetadata) * mi.argument_count);
if (mi.argument_count != p_method.arguments_metadata.size()) {
WARN_PRINT("Mismatch argument metadata count for virtual method: " + String(p_class) + "::" + p_method.name);
}
for (uint32_t i = 0; i < mi.argument_count; i++) {
mi.arguments[i] = p_method.arguments[i]._to_gdextension();
mi.arguments_metadata[i] = p_method.arguments_metadata[i];
if (i < p_method.arguments_metadata.size()) {
mi.arguments_metadata[i] = p_method.arguments_metadata[i];
}
}
} else {
mi.arguments = nullptr;
Expand Down

0 comments on commit 1e169bb

Please sign in to comment.