[Lldb-commits] [lldb] r183706 - <rdar://problem/14101771>

Enrico Granata egranata at apple.com
Mon Jun 10 15:26:15 PDT 2013


Author: enrico
Date: Mon Jun 10 17:26:15 2013
New Revision: 183706

URL: http://llvm.org/viewvc/llvm-project?rev=183706&view=rev
Log:
<rdar://problem/14101771>

Hardening the CFBitVector data formatter against failed reads

Modified:
    lldb/trunk/source/DataFormatters/CF.cpp

Modified: lldb/trunk/source/DataFormatters/CF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CF.cpp?rev=183706&r1=183705&r2=183706&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CF.cpp (original)
+++ lldb/trunk/source/DataFormatters/CF.cpp Mon Jun 10 17:26:15 2013
@@ -157,11 +157,12 @@ lldb_private::formatters::CFBitVectorSum
         num_bytes = 1024;
     DataBufferSP buffer_sp(new DataBufferHeap(num_bytes,0));
     num_bytes = process_sp->ReadMemory(data_ptr, buffer_sp->GetBytes(), num_bytes, error);
-    if (error.Fail())
+    if (error.Fail() || num_bytes == 0)
         return false;
+    uint8_t *bytes = buffer_sp->GetBytes();
     for (int byte_idx = 0; byte_idx < num_bytes-1; byte_idx++)
     {
-        uint8_t byte = buffer_sp->GetBytes()[byte_idx];
+        uint8_t byte = bytes[byte_idx];
         bool bit0 = (byte & 1) == 1;
         bool bit1 = (byte & 2) == 2;
         bool bit2 = (byte & 4) == 4;
@@ -183,7 +184,7 @@ lldb_private::formatters::CFBitVectorSum
     }
     {
         // print the last byte ensuring we do not print spurious bits
-        uint8_t byte = buffer_sp->GetBytes()[num_bytes-1];
+        uint8_t byte = bytes[num_bytes-1];
         bool bit0 = (byte & 1) == 1;
         bool bit1 = (byte & 2) == 2;
         bool bit2 = (byte & 4) == 4;





More information about the lldb-commits mailing list