summaryrefslogtreecommitdiff
path: root/lib/ProfileData
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-04-25 02:45:33 +0000
committerJustin Bogner <mail@justinbogner.com>2014-04-25 02:45:33 +0000
commit38ac7e92d8a489cc24c8bb877db2468cb80b55e2 (patch)
tree0f70bcfa1748a7f25cb7daf014ac5be7d4f3aaa8 /lib/ProfileData
parentb33022e1da567d52163b1b621f5746d10814232c (diff)
downloadllvm-38ac7e92d8a489cc24c8bb877db2468cb80b55e2.tar.gz
llvm-38ac7e92d8a489cc24c8bb877db2468cb80b55e2.tar.bz2
llvm-38ac7e92d8a489cc24c8bb877db2468cb80b55e2.tar.xz
ProfileData: Treat missing function counts as malformed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207172 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ProfileData')
-rw-r--r--lib/ProfileData/InstrProfReader.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/ProfileData/InstrProfReader.cpp b/lib/ProfileData/InstrProfReader.cpp
index 4f110a5712..12c3c8256b 100644
--- a/lib/ProfileData/InstrProfReader.cpp
+++ b/lib/ProfileData/InstrProfReader.cpp
@@ -101,6 +101,8 @@ error_code TextInstrProfReader::readNextRecord(InstrProfRecord &Record) {
return error(instrprof_error::truncated);
if ((Line++)->getAsInteger(10, NumCounters))
return error(instrprof_error::malformed);
+ if (NumCounters == 0)
+ return error(instrprof_error::malformed);
// Read each counter and fill our internal storage with the values.
Counts.clear();
@@ -210,8 +212,10 @@ RawInstrProfReader<IntPtrT>::readNextRecord(InstrProfRecord &Record) {
// Get the raw data.
StringRef RawName(getName(Data->NamePtr), swap(Data->NameSize));
- auto RawCounts = makeArrayRef(getCounter(Data->CounterPtr),
- swap(Data->NumCounters));
+ uint32_t NumCounters = swap(Data->NumCounters);
+ if (NumCounters == 0)
+ return error(instrprof_error::malformed);
+ auto RawCounts = makeArrayRef(getCounter(Data->CounterPtr), NumCounters);
// Check bounds.
auto *NamesStartAsCounter = reinterpret_cast<const uint64_t *>(NamesStart);