diff --git a/source/Plugins/LanguageRuntime/Rust/RustLanguageRuntime.cpp b/source/Plugins/LanguageRuntime/Rust/RustLanguageRuntime.cpp index 7df8fd6e4e..8c91e5fd7c 100644 --- a/source/Plugins/LanguageRuntime/Rust/RustLanguageRuntime.cpp +++ b/source/Plugins/LanguageRuntime/Rust/RustLanguageRuntime.cpp @@ -98,6 +98,9 @@ bool RustLanguageRuntime::GetDynamicTypeAndAddress( } CompilerType variant_type = ast->FindEnumVariant(type, discriminant); + if (!variant_type) { + return false; + } class_type_or_name = TypeAndOrName(variant_type); // The address doesn't change. dynamic_address.SetLoadAddress(original_ptr, exe_ctx.GetTargetPtr()); diff --git a/source/Symbol/RustASTContext.cpp b/source/Symbol/RustASTContext.cpp index c5f010c9a3..1025258582 100644 --- a/source/Symbol/RustASTContext.cpp +++ b/source/Symbol/RustASTContext.cpp @@ -625,6 +625,10 @@ class RustEnum : public RustAggregateBase { int idx = m_default; if (iter != m_discriminants.end()) { idx = iter->second; + } else if (idx == -1) { + // If the DWARF was bad somehow, we could end up not finding the + // discriminant and not having a default. + return CompilerType(); } return FieldAt(idx)->m_type; }