[Lldb-commits] [lldb] [lldb-vscode] Fix a GetChildAtIndex call (PR #65537)
Walter Erquinigo via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 6 14:48:53 PDT 2023
https://github.com/walter-erquinigo created https://github.com/llvm/llvm-project/pull/65537:
We were invoking GetChildAtIndex(0) without checking the number of children.
This was not crashing but was showing some warnings in python formatters.
>From 78d2b81b4a6fb55b98b42f6e3edd0f6d96f20fd8 Mon Sep 17 00:00:00 2001
From: walter erquinigo <walter at modular.com>
Date: Wed, 6 Sep 2023 17:40:28 -0400
Subject: [PATCH] [lldb-vscode] Fix a GetChildAtIndex call
We were invoking GetChildAtIndex(0) without checking the number of children.
This was not crashing but was showing some warnings in python formatters.
---
lldb/tools/lldb-vscode/JSONUtils.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 8cfe6dfeb667d85..9a6fd26d2bd5864 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -1133,7 +1133,7 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
const auto num_children = v.GetNumChildren();
if (is_array) {
object.try_emplace("indexedVariables", num_children);
- } else {
+ } else if (num_children > 0) {
// If a type has a synthetic child provider, then the SBType of "v" won't
// tell us anything about what might be displayed. So we can check if the
// first child's name is "[0]" and then we can say it is indexed.
More information about the lldb-commits
mailing list