diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-05-27 18:49:58 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-05-27 18:49:58 +0000 |
| commit | 1d69da52798dc6fb274d733fa1656ef365e2b5b7 (patch) | |
| tree | a031003eee765d6df83ad104ccd7d6a862c9b0f6 | |
| parent | bccdf597fbcdab352752552f781169639e6d402a (diff) | |
| download | bcm5719-llvm-1d69da52798dc6fb274d733fa1656ef365e2b5b7.tar.gz bcm5719-llvm-1d69da52798dc6fb274d733fa1656ef365e2b5b7.zip | |
Don't assume that there will be enough padding bytes
llvm-svn: 271030
| -rw-r--r-- | llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h b/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h index f9184895d8d..6d260900257 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h +++ b/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h @@ -97,7 +97,7 @@ public: void visitTypeBegin(TypeLeafKind Leaf, ArrayRef<uint8_t> RecordData) {} void visitTypeEnd(TypeLeafKind Leaf, ArrayRef<uint8_t> RecordData) {} - static ArrayRef<uint8_t> skipPadding(ArrayRef<uint8_t> Data) { + ArrayRef<uint8_t> skipPadding(ArrayRef<uint8_t> Data) { if (Data.empty()) return Data; uint8_t Leaf = Data.front(); @@ -105,7 +105,12 @@ public: return Data; // Leaf is greater than 0xf0. We should advance by the number of bytes in // the low 4 bits. - return Data.drop_front(Leaf & 0x0F); + unsigned BytesToAdvance = Leaf & 0x0F; + if (Data.size() < BytesToAdvance) { + parseError(); + return None; + } + return Data.drop_front(BytesToAdvance); } /// Visits individual member records of a field list record. Member records do @@ -137,6 +142,8 @@ public: #include "TypeRecords.def" } FieldData = skipPadding(FieldData); + if (hadError()) + break; } } |

