[Lldb-commits] [PATCH] D142341: [LLDB][NFC] Fix a null pointer check in LibCxx.cpp

Shivam Gupta via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 23 02:54:29 PST 2023


xgupta created this revision.
xgupta added a reviewer: DavidSpickett.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The issue is that the SyntheticChildrenFrontEnd constructor is being
called with the dereferenced valobj_sp pointer, before the valobj_sp
pointer is verified to be non-null inside the body of the constructor function.

To fix this issue, we have move the call to the SyntheticChildrenFrontEnd
constructor to after the null check for valobj_sp in the constructor
function body, so that it will only be called if valobj_sp is non-null.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142341

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===================================================================
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -220,8 +220,9 @@
 
 lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
     LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
-    : SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() {
+    : m_pair_ptr(), m_pair_sp() {
   if (valobj_sp)
+    SyntheticChildrenFrontEnd(*valobj_sp);
     Update();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142341.491274.patch
Type: text/x-patch
Size: 581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230123/8c762692/attachment.bin>


More information about the lldb-commits mailing list