diff options
| author | Enrico Granata <egranata@apple.com> | 2013-06-10 22:26:15 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2013-06-10 22:26:15 +0000 |
| commit | 4c648b188423fb82107e40fc187ab676223581c7 (patch) | |
| tree | 9f0247c4364119020edfa04d67071c6e109a57cd | |
| parent | 787ee4e099db1b712829cef9e75ba72d6d2e0c8d (diff) | |
| download | bcm5719-llvm-4c648b188423fb82107e40fc187ab676223581c7.tar.gz bcm5719-llvm-4c648b188423fb82107e40fc187ab676223581c7.zip | |
<rdar://problem/14101771>
Hardening the CFBitVector data formatter against failed reads
llvm-svn: 183706
| -rw-r--r-- | lldb/source/DataFormatters/CF.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lldb/source/DataFormatters/CF.cpp b/lldb/source/DataFormatters/CF.cpp index bb1cbafc2a8..ad1662983df 100644 --- a/lldb/source/DataFormatters/CF.cpp +++ b/lldb/source/DataFormatters/CF.cpp @@ -157,11 +157,12 @@ lldb_private::formatters::CFBitVectorSummaryProvider (ValueObject& valobj, Strea 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::CFBitVectorSummaryProvider (ValueObject& valobj, Strea } { // 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; |

