From 9b27354f6f3e9086d5f7abbc373b617209fc35b2 Mon Sep 17 00:00:00 2001 From: dim Date: Tue, 9 Jun 2015 19:06:30 +0000 Subject: Vendor import of llvm trunk r239412: https://llvm.org/svn/llvm-project/llvm/trunk@239412 --- lib/ProfileData/CoverageMappingReader.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/ProfileData/CoverageMappingReader.cpp') diff --git a/lib/ProfileData/CoverageMappingReader.cpp b/lib/ProfileData/CoverageMappingReader.cpp index cf6cd58..ec531c3 100644 --- a/lib/ProfileData/CoverageMappingReader.cpp +++ b/lib/ProfileData/CoverageMappingReader.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Endian.h" #include "llvm/Support/LEB128.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -358,8 +359,12 @@ std::error_code readCoverageMappingData( const char *CovBuf = Buf; Buf += CoverageSize; const char *CovEnd = Buf; + if (Buf > End) return coveragemap_error::malformed; + // Each coverage map has an alignment of 8, so we need to adjust alignment + // before reading the next map. + Buf += alignmentAdjustment(Buf, 8); while (FunBuf < FunEnd) { // Read the function information -- cgit v1.1