[lld] r227510 - ELF: Check StringRef::getAsInteger's return value.
Rui Ueyama
ruiu at google.com
Thu Jan 29 15:23:57 PST 2015
Author: ruiu
Date: Thu Jan 29 17:23:57 2015
New Revision: 227510
URL: http://llvm.org/viewvc/llvm-project?rev=227510&view=rev
Log:
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.
Modified:
lld/trunk/lib/ReaderWriter/ELF/ArrayOrderPass.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/ArrayOrderPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ArrayOrderPass.cpp?rev=227510&r1=227509&r2=227510&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ArrayOrderPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ArrayOrderPass.cpp Thu Jan 29 17:23:57 2015
@@ -42,13 +42,12 @@ void ArrayOrderPass::perform(std::unique
// according to their number. Sections without optional
// numer suffix should go last.
- uint32_t leftPriority = std::numeric_limits<uint32_t>::max();
- if (!leftNum.empty())
- leftNum.getAsInteger(10, leftPriority);
-
- uint32_t rightPriority = std::numeric_limits<uint32_t>::max();
- if (!rightNum.empty())
- rightNum.getAsInteger(10, rightPriority);
+ uint32_t leftPriority;
+ uint32_t rightPriority;
+ if (leftNum.getAsInteger(10, leftPriority))
+ leftPriority = std::numeric_limits<uint32_t>::max();
+ if (rightNum.getAsInteger(10, rightPriority))
+ rightPriority = std::numeric_limits<uint32_t>::max();
return leftPriority < rightPriority;
});
More information about the llvm-commits
mailing list