[Lldb-commits] [lldb] a72306e - [lldb] Fix TestDataFormatterLibcxxString broken by D129490

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 12 11:12:44 PDT 2022


Author: Pavel Labath
Date: 2022-07-12T20:12:22+02:00
New Revision: a72306e202eedaed7c1a25caf4565bf5577110ce

URL: https://github.com/llvm/llvm-project/commit/a72306e202eedaed7c1a25caf4565bf5577110ce
DIFF: https://github.com/llvm/llvm-project/commit/a72306e202eedaed7c1a25caf4565bf5577110ce.diff

LOG: [lldb] Fix TestDataFormatterLibcxxString broken by D129490

We need to check for the error inside the value object to avoid reading
garbage through invalid (target) pointers.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index aaf346414d22..3b04b3a1b2ac 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -725,7 +725,7 @@ static llvm::Optional<std::pair<uint64_t, ValueObjectSP>>
 ExtractLibcxxStringInfo(ValueObject &valobj) {
   ValueObjectSP valobj_r_sp =
       valobj.GetChildMemberWithName(ConstString("__r_"), /*can_create=*/true);
-  if (!valobj_r_sp)
+  if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
     return {};
 
   // __r_ is a compressed_pair of the actual data and the allocator. The data we


        


More information about the lldb-commits mailing list