diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-04-07 00:46:49 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-04-07 00:46:49 +0000 |
commit | 6e95bfc6a5bfd659ab6166a840a190e077ff5067 (patch) | |
tree | dc6f11e5a17a54ebc964b6daad4e0156a1919677 /clang/lib/Checker/Store.cpp | |
parent | 8e36d53e34be6d74ce4fa76b2b5cb586d32da51b (diff) | |
download | bcm5719-llvm-6e95bfc6a5bfd659ab6166a840a190e077ff5067.tar.gz bcm5719-llvm-6e95bfc6a5bfd659ab6166a840a190e077ff5067.zip |
Fix crash in StoreManager::CastRegion() when the base region is a type with 0 size.
llvm-svn: 100594
Diffstat (limited to 'clang/lib/Checker/Store.cpp')
-rw-r--r-- | clang/lib/Checker/Store.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/Checker/Store.cpp b/clang/lib/Checker/Store.cpp index e524cb3d7cc..80b6586b8b9 100644 --- a/clang/lib/Checker/Store.cpp +++ b/clang/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; + } } } |