summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-05-27 18:50:02 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-05-27 18:50:02 +0000
commit6c13db402f9141851f93cdc5818de28f0b9d757b (patch)
treed527b350ff9c87a85911d748a9743d1d52ab3591 /llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
parent0e872f6475c389de95dd48eb17a55117db48095e (diff)
downloadbcm5719-llvm-6c13db402f9141851f93cdc5818de28f0b9d757b.tar.gz
bcm5719-llvm-6c13db402f9141851f93cdc5818de28f0b9d757b.zip
Make sure data is available before dereferencing it
llvm-svn: 271032
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
index c142a01ef33..ab9206a33ec 100644
--- a/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
+++ b/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp
@@ -45,6 +45,8 @@ std::error_code llvm::codeview::consume(ArrayRef<uint8_t> &Data, APSInt &Num) {
}
switch (Short) {
case LF_CHAR:
+ if (Data.size() < 1)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/8,
*reinterpret_cast<const int8_t *>(Data.data()),
/*isSigned=*/true),
@@ -52,6 +54,8 @@ std::error_code llvm::codeview::consume(ArrayRef<uint8_t> &Data, APSInt &Num) {
Data = Data.drop_front(1);
return std::error_code();
case LF_SHORT:
+ if (Data.size() < 2)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/16,
*reinterpret_cast<const little16_t *>(Data.data()),
/*isSigned=*/true),
@@ -59,6 +63,8 @@ std::error_code llvm::codeview::consume(ArrayRef<uint8_t> &Data, APSInt &Num) {
Data = Data.drop_front(2);
return std::error_code();
case LF_USHORT:
+ if (Data.size() < 2)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/16,
*reinterpret_cast<const ulittle16_t *>(Data.data()),
/*isSigned=*/false),
@@ -66,6 +72,8 @@ std::error_code llvm::codeview::consume(ArrayRef<uint8_t> &Data, APSInt &Num) {
Data = Data.drop_front(2);
return std::error_code();
case LF_LONG:
+ if (Data.size() < 4)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/32,
*reinterpret_cast<const little32_t *>(Data.data()),
/*isSigned=*/true),
@@ -73,6 +81,8 @@ std::error_code llvm::codeview::consume(ArrayRef<uint8_t> &Data, APSInt &Num) {
Data = Data.drop_front(4);
return std::error_code();
case LF_ULONG:
+ if (Data.size() < 4)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/32,
*reinterpret_cast<const ulittle32_t *>(Data.data()),
/*isSigned=*/FalseVal),
@@ -80,6 +90,8 @@ std::error_code llvm::codeview::consume(ArrayRef<uint8_t> &Data, APSInt &Num) {
Data = Data.drop_front(4);
return std::error_code();
case LF_QUADWORD:
+ if (Data.size() < 8)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/64,
*reinterpret_cast<const little64_t *>(Data.data()),
/*isSigned=*/true),
@@ -87,6 +99,8 @@ std::error_code llvm::codeview::consume(ArrayRef<uint8_t> &Data, APSInt &Num) {
Data = Data.drop_front(8);
return std::error_code();
case LF_UQUADWORD:
+ if (Data.size() < 8)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/64,
*reinterpret_cast<const ulittle64_t *>(Data.data()),
/*isSigned=*/false),
OpenPOWER on IntegriCloud