[Lldb-commits] [lldb] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69253)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 16 16:02:44 PDT 2023
================
@@ -914,6 +914,11 @@ def get_variant_npos_value(index_byte_size):
if index == npos_value:
return " No Value"
+ # Invalid index can happen when the variant is not initialized yet.
+ template_arg_count = data_obj.GetType().GetNumberOfTemplateArguments()
+ if index >= template_arg_count:
+ return " <Invalid>"
+
active_type = data_obj.GetType().GetTemplateArgumentType(index)
----------------
clayborg wrote:
If this is what was crashing, we should modify the GetTemplateArgumentType(<index>) to not crash with an inalid index as part of this fix.
https://github.com/llvm/llvm-project/pull/69253
More information about the lldb-commits
mailing list