diff options
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfReader.cpp')
-rw-r--r-- | llvm/lib/ProfileData/InstrProfReader.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index b904f983dcebe..16a69cb5457b8 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/ProfileSummary.h" #include "llvm/ProfileData/InstrProf.h" @@ -144,7 +145,7 @@ bool TextInstrProfReader::hasFormat(const MemoryBuffer &Buffer) { StringRef buffer = Buffer.getBufferStart(); return count == 0 || std::all_of(buffer.begin(), buffer.begin() + count, - [](char c) { return isPrint(c) || ::isspace(c); }); + [](char c) { return isPrint(c) || isSpace(c); }); } // Read the profile variant flag from the header: ":FE" means this is a FE @@ -422,11 +423,11 @@ Error RawInstrProfReader<IntPtrT>::readRawCounts( // Check bounds. Note that the counter pointer embedded in the data record // may itself be corrupt. - if (NumCounters > MaxNumCounters) + if (MaxNumCounters < 0 || NumCounters > (uint32_t)MaxNumCounters) return error(instrprof_error::malformed); ptrdiff_t CounterOffset = getCounterOffset(CounterPtr); if (CounterOffset < 0 || CounterOffset > MaxNumCounters || - (CounterOffset + NumCounters) > MaxNumCounters) + ((uint32_t)CounterOffset + NumCounters) > (uint32_t)MaxNumCounters) return error(instrprof_error::malformed); auto RawCounts = makeArrayRef(getCounter(CounterOffset), NumCounters); |