summaryrefslogtreecommitdiffstats
path: root/clang/lib/Checker/RegionStore.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-14 23:08:34 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-14 23:08:34 +0000
commitc95589d2e69d65d2ed65862f3f73e217e62ff286 (patch)
tree4db0e208d1e16bb3b65a3d205bc4efa23297f006 /clang/lib/Checker/RegionStore.cpp
parent8b9126694d75084cec4b0e1f482d7daae09bbe27 (diff)
downloadbcm5719-llvm-c95589d2e69d65d2ed65862f3f73e217e62ff286.tar.gz
bcm5719-llvm-c95589d2e69d65d2ed65862f3f73e217e62ff286.zip
Don't divide-by-zero in RegionStoreManager::getSizeInElements() when getting the size of a VLA. We don't track VLA extents yet,
but we should at least not crash. Fixes <rdar://problem/8424269>. llvm-svn: 113888
Diffstat (limited to 'clang/lib/Checker/RegionStore.cpp')
-rw-r--r--clang/lib/Checker/RegionStore.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Checker/RegionStore.cpp b/clang/lib/Checker/RegionStore.cpp
index 1a3eded7cb0..8c3763778d8 100644
--- a/clang/lib/Checker/RegionStore.cpp
+++ b/clang/lib/Checker/RegionStore.cpp
@@ -745,6 +745,14 @@ DefinedOrUnknownSVal RegionStoreManager::getSizeInElements(const GRState *state,
return UnknownVal();
CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+ if (Ctx.getAsVariableArrayType(EleTy)) {
+ // FIXME: We need to track extra state to properly record the size
+ // of VLAs. Returning UnknownVal here, however, is a stop-gap so that
+ // we don't have a divide-by-zero below.
+ return UnknownVal();
+ }
+
CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
// If a variable is reinterpreted as a type that doesn't fit into a larger
OpenPOWER on IntegriCloud