diff options
author | Kaelyn Uhrain <rikka@google.com> | 2011-08-10 18:49:28 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2011-08-10 18:49:28 +0000 |
commit | e535376b14dfd26508300240915463b8ff8654ff (patch) | |
tree | 1a658b2eee25ae98100afbfab19c00aa7234da3e /clang/lib/Sema/SemaChecking.cpp | |
parent | 50c0912492e265c87a64cb90f20f91c5ac7b9af5 (diff) | |
download | bcm5719-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.cpp | 1 |
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; |