summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2015-01-07 02:42:01 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2015-01-07 02:42:01 +0000
commitc7db7f0454ed93e52875bedc3b76a08f92291445 (patch)
tree009c2a56678b6efc2bd2b997fdf3aa45bf41ed53 /llvm/lib/Object/MachOObjectFile.cpp
parent7ad02fca09a8451b6c2c37ce6d1094f212f7720c (diff)
downloadbcm5719-llvm-c7db7f0454ed93e52875bedc3b76a08f92291445.tar.gz
bcm5719-llvm-c7db7f0454ed93e52875bedc3b76a08f92291445.zip
[ADT][SmallVector] Flip an assert comparison to avoid overflows yielding false-negatives. NFC.
r221973 changed SmallVector::operator[] to use size_t instead of unsigned. Before that, on 64bit platforms, when a large index (say -1) was passed, truncating it to unsigned avoided an overflow when computing 'begin() + idx', and failed the range checking assertion, as expected. With r221973, idx isn't truncated, so the addition wraps to '(char*)begin() - 1', and doesn't fire anymore when it should have done so. This commit changes the comparison to instead compute 'end() - begin()' (i.e., 'size()'), which avoids potentially overflowing additions, and correctly triggers the assertion when values such as -1 are passed. Note that the problem already existed before that revision, on platforms where sizeof(size_t) == sizeof(unsigned). llvm-svn: 225338
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud