summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2011-08-10 18:49:28 +0000
committerKaelyn Uhrain <rikka@google.com>2011-08-10 18:49:28 +0000
commite535376b14dfd26508300240915463b8ff8654ff (patch)
tree1a658b2eee25ae98100afbfab19c00aa7234da3e /clang/lib/Sema/SemaChecking.cpp
parent50c0912492e265c87a64cb90f20f91c5ac7b9af5 (diff)
downloadbcm5719-llvm-e535376b14dfd26508300240915463b8ff8654ff.tar.gz
bcm5719-llvm-e535376b14dfd26508300240915463b8ff8654ff.zip
Make sure ptrarith_typesize is at least 1 to avoid division by zero
llvm-svn: 137234
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index d3332f7b560..d1fa1965693 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3553,6 +3553,7 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
// Make sure we're comparing apples to apples when comparing index to size
uint64_t ptrarith_typesize = Context.getTypeSize(EffectiveType);
uint64_t array_typesize = Context.getTypeSize(BaseType);
+ if (!ptrarith_typesize) ptrarith_typesize = 1;
if (ptrarith_typesize != array_typesize) {
// There's a cast to a different size type involved
uint64_t ratio = array_typesize / ptrarith_typesize;
OpenPOWER on IntegriCloud