diff options
| author | Kai <kai@kana.jetzt> | 2024-05-07 08:05:23 +0200 |
|---|---|---|
| committer | Kai <kai@kana.jetzt> | 2024-05-07 08:07:11 +0200 |
| commit | f4192aad6f6c46075c598ad9d6773fd919ced7fc (patch) | |
| tree | 9043035901b43b81de57d1571501003cbe9d2755 | |
| parent | 7cdad333114e6765351ed0facb48db228ef29b7b (diff) | |
| download | redot-engine-f4192aad6f6c46075c598ad9d6773fd919ced7fc.tar.gz | |
Fix crash when extending taken-over named class
Added error handling in `_prepare_compilation()` to address cases where the `base_type` cannot be found, preventing a crash.
| -rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index a8a7f3d9f7..35f5d0ed54 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -2666,7 +2666,10 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP GDScriptDataType base_type = _gdtype_from_datatype(p_class->base_type, p_script, false); + ERR_FAIL_COND_V_MSG(base_type.native_type == StringName(), ERR_BUG, vformat(R"(Failed to get base class for "%s")", p_script->path)); + int native_idx = GDScriptLanguage::get_singleton()->get_global_map()[base_type.native_type]; + p_script->native = GDScriptLanguage::get_singleton()->get_global_array()[native_idx]; ERR_FAIL_COND_V(p_script->native.is_null(), ERR_BUG); |
