]> granicus.if.org Git - clang/commitdiff
Make sure ptrarith_typesize is at least 1 to avoid division by zero
authorKaelyn Uhrain <rikka@google.com>
Wed, 10 Aug 2011 18:49:28 +0000 (18:49 +0000)
committerKaelyn Uhrain <rikka@google.com>
Wed, 10 Aug 2011 18:49:28 +0000 (18:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137234 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp

index d3332f7b56094c04b36e7f33747a5858b42f3f87..d1fa196569315aba38c905ed4bb152a2a6b2ec2b 100644 (file)
@@ -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;