diff options
author | David Snopek <dsnopek@gmail.com> | 2024-11-05 09:18:01 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-05 09:18:01 -0600 |
commit | 253e095c815158184c9ec044fd0699d93c68675d (patch) | |
tree | 1068a4c65030c80f33f105507553506252dcb28b | |
parent | 259c757ccea4c8e223713019ca5ab95788fcf92e (diff) | |
parent | 1e169bb8091e18c0cf98261af9cd843602eb8175 (diff) | |
download | redot-cpp-253e095c815158184c9ec044fd0699d93c68675d.tar.gz |
Merge pull request #1581 from dsnopek/classdb-add-virtual-method-arg-metadata-size
Fix crash in `ClassDB::add_virtual_method()` if arguments metadata is the wrong size
-rw-r--r-- | src/core/class_db.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/class_db.cpp b/src/core/class_db.cpp index 5ded799..ae74f2c 100644 --- a/src/core/class_db.cpp +++ b/src/core/class_db.cpp @@ -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; |