[Lldb-commits] [lldb] [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69614)

via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 19 11:11:19 PDT 2023


================
@@ -7183,7 +7183,8 @@ GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl,
   // (including the ones preceding the parameter pack).
   const auto &pack = args[last_idx];
   const size_t pack_idx = idx - last_idx;
-  assert(pack_idx < pack.pack_size() && "parameter pack index out-of-bounds");
+  if (pack_idx >= pack.pack_size())
+    return nullptr;
----------------
jeffreytan81 wrote:

It is requested by @clayborg's comment in the original patch:
```
If this is what was crashing, we should modify the GetTemplateArgumentType() to not crash with an inalid index as part of this fix.
```

https://github.com/llvm/llvm-project/pull/69614


More information about the lldb-commits mailing list