This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Ensure SBStructuredData::m_impl_up is always non-null
ClosedPublic

Authored by kastiglione on Apr 29 2021, 4:06 PM.

Details

Summary

By ensuring that SBStructuredData::m_impl_up always has a value, it prevents crashes that can happen when the SBStructuredDataImpl is null.

This fixes a case that caused SBStructuredData::operator= to crash. This happened when rhs had a null SBStructuredDataImpl.

Diff Detail

Event Timeline

kastiglione requested review of this revision.Apr 29 2021, 4:06 PM
kastiglione created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2021, 4:06 PM
shafik added a subscriber: shafik.Apr 29 2021, 4:39 PM

LGTM, it seems like there a few places where we are not consistently checking m_impl_up is valid and other places we are using the conditional operator to check if it is set or not.

I should expand this to fix other unchecked dereferences.

Ensure m_impl_up is always non-null

kastiglione retitled this revision from [lldb] Handle missing SBStructuredData copy assignment cases to [lldb] Ensure SBStructuredData::m_impl_up is always non-null.Apr 29 2021, 5:24 PM
kastiglione edited the summary of this revision. (Show Details)

I changed direction, to ensure the impl pointer is always non-null.

lldb/source/API/SBStructuredData.cpp
43

This is the key change, all else is cleanup.

LGTM. I'm going to be that guy and ask if you could test this (there is an API unittest directory with an example test, so copying that and just exercising the nullptr SBStructuredData is good enough).

This revision is now accepted and ready to land.Apr 30 2021, 8:45 AM

Add unittest

This revision was landed with ongoing or failed builds.May 5 2021, 3:12 PM
This revision was automatically updated to reflect the committed changes.