[llvm] r271030 - Don't assume that there will be enough padding bytes

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 11:49:58 PDT 2016


Author: majnemer
Date: Fri May 27 13:49:58 2016
New Revision: 271030

URL: http://llvm.org/viewvc/llvm-project?rev=271030&view=rev
Log:
Don't assume that there will be enough padding bytes

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h?rev=271030&r1=271029&r2=271030&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h Fri May 27 13:49:58 2016
@@ -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;
     }
   }
 




More information about the llvm-commits mailing list