Skip to content

Commit b8c64e2

Browse files
committed
[lLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName.
LLDB can crash in TypeSystemClang::GetIndexOfChildMemberWithName, at a point where it pushes an index onto the child_indexes vector, tries to call itself recursively, then tries to pop the entry from child_indexes. The problem is that the recursive call can clear child_indexes, so that this code ends up trying to pop an already empty vector. This change saves the old vector before the push, then restores the saved vector rather than trying to pop.
1 parent 8458bbe commit b8c64e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
67546754
llvm::StringRef field_name = field->getName();
67556755
if (field_name.empty()) {
67566756
CompilerType field_type = GetType(field->getType());
6757+
std::vector<uint32_t> save_indices = child_indexes;
67576758
child_indexes.push_back(child_idx);
67586759
if (field_type.GetIndexOfChildMemberWithName(
67596760
name, omit_empty_base_classes, child_indexes))
67606761
return child_indexes.size();
6761-
child_indexes.pop_back();
6762-
6762+
child_indexes = save_indices;
67636763
} else if (field_name == name) {
67646764
// We have to add on the number of base classes to this index!
67656765
child_indexes.push_back(

0 commit comments

Comments
 (0)