diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-24 19:35:33 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-24 19:35:33 +0000 |
commit | e95db4f2cd3ed4825a179bd7f151a5fc86b38e6f (patch) | |
tree | f7ba7fd385e05f2e1f73c083ca2deb2c979a936c /lib/Analysis/RegionStore.cpp | |
parent | a68c106ed270c9161240e4d3716aa1201347ae48 (diff) |
Fix crash of array bounds checking under 64-bit.
There might be other, similar bugs lurking there.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59974 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/RegionStore.cpp')
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 9a1f3eca34..747b16d7b6 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -254,12 +254,15 @@ SVal RegionStoreManager::getLValueElement(const GRState* St, if ((CI1 = dyn_cast<nonloc::ConcreteInt>(&Idx)) && (CI2 = dyn_cast<nonloc::ConcreteInt>(&Offset))) { - // Temporary SVal to hold a potential signed APSInt. + // Temporary SVal to hold a potential signed and extended APSInt. SVal SignedInt; - // Index might be unsigned. We have to convert it to signed. - if (CI2->getValue().isUnsigned()) { + // Index might be unsigned. We have to convert it to signed. It might also + // be less wide than the size. We have to extend it. + if (CI2->getValue().isUnsigned() || + CI2->getValue().getBitWidth() < CI1->getValue().getBitWidth()) { llvm::APSInt SI = CI2->getValue(); + SI.extend(CI1->getValue().getBitWidth()); SI.setIsSigned(true); SignedInt = nonloc::ConcreteInt(getBasicVals().getValue(SI)); CI2 = cast<nonloc::ConcreteInt>(&SignedInt); |