[lldb/Core] Fix crash in ValueObject::CreateChildAtIndex

The patch fixes a crash in ValueObject::CreateChildAtIndex caused by a
null pointer dereferencing. This is a corner case that is happening when
trying to dereference a variable with an incomplete type, and this same
variable doesn't have a synthetic value to get the child ValueObject.

If this happens, lldb will now return a null pointer that will results
in an error message.

rdar://65181171

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
Med Ismail Bennani
2020-07-07 18:45:30 +02:00
parent 9dfea03517
commit 7177e63fb5
6 changed files with 20 additions and 56 deletions

View File

@@ -687,10 +687,15 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
language_flags);
}
if (!valobj && synthetic_array_member)
valobj = GetSyntheticValue()
->GetChildAtIndex(synthetic_index, synthetic_array_member)
.get();
// In case of an incomplete type, LLDB will try to use the ValueObject's
// synthetic value to create the child ValueObject.
if (!valobj && synthetic_array_member) {
if (ValueObjectSP synth_valobj_sp = GetSyntheticValue()) {
valobj = synth_valobj_sp
->GetChildAtIndex(synthetic_index, synthetic_array_member)
.get();
}
}
return valobj;
}