ELF: Check StringRef::getAsInteger's return value.

getAsInteger may partially update its result argument. We need to
check function return value to handle errors reliably.

llvm-svn: 227510
This commit is contained in:
Rui Ueyama 2015-01-29 23:23:57 +00:00
parent 0f776b0905
commit c1fa8300ec
1 changed files with 6 additions and 7 deletions

View File

@ -42,13 +42,12 @@ void ArrayOrderPass::perform(std::unique_ptr<MutableFile> &f) {
// according to their number. Sections without optional // according to their number. Sections without optional
// numer suffix should go last. // numer suffix should go last.
uint32_t leftPriority = std::numeric_limits<uint32_t>::max(); uint32_t leftPriority;
if (!leftNum.empty()) uint32_t rightPriority;
leftNum.getAsInteger(10, leftPriority); if (leftNum.getAsInteger(10, leftPriority))
leftPriority = std::numeric_limits<uint32_t>::max();
uint32_t rightPriority = std::numeric_limits<uint32_t>::max(); if (rightNum.getAsInteger(10, rightPriority))
if (!rightNum.empty()) rightPriority = std::numeric_limits<uint32_t>::max();
rightNum.getAsInteger(10, rightPriority);
return leftPriority < rightPriority; return leftPriority < rightPriority;
}); });