aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker/Store.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-04-07 00:46:49 +0000
committerTed Kremenek <kremenek@apple.com>2010-04-07 00:46:49 +0000
commit974d97b251aaf5a735af83367cd3a930f3eb4333 (patch)
tree8db0d8d2d7a7f312f0df35c26da10b51dbf15e1a /lib/Checker/Store.cpp
parentc91cc66e92b084acd1fdbaa1c3c74242741b3d46 (diff)
Fix crash in StoreManager::CastRegion() when the base region is a type with 0 size.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100594 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/Store.cpp')
-rw-r--r--lib/Checker/Store.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Checker/Store.cpp b/lib/Checker/Store.cpp
index e524cb3d7c..80b6586b8b 100644
--- a/lib/Checker/Store.cpp
+++ b/lib/Checker/Store.cpp
@@ -170,13 +170,14 @@ const MemRegion *StoreManager::CastRegion(const MemRegion *R, QualType CastToTy)
if (IsCompleteType(Ctx, PointeeTy)) {
// Compute the size in **bytes**.
CharUnits pointeeTySize = Ctx.getTypeSizeInChars(PointeeTy);
-
- // Is the offset a multiple of the size? If so, we can layer the
- // ElementRegion (with elementType == PointeeTy) directly on top of
- // the base region.
- if (off % pointeeTySize == 0) {
- newIndex = off / pointeeTySize;
- newSuperR = baseR;
+ if (!pointeeTySize.isZero()) {
+ // Is the offset a multiple of the size? If so, we can layer the
+ // ElementRegion (with elementType == PointeeTy) directly on top of
+ // the base region.
+ if (off % pointeeTySize == 0) {
+ newIndex = off / pointeeTySize;
+ newSuperR = baseR;
+ }
}
}