From: Kaelyn Uhrain Date: Wed, 10 Aug 2011 18:49:28 +0000 (+0000) Subject: Make sure ptrarith_typesize is at least 1 to avoid division by zero X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18f169770d9d3f826bad8f1359c8c5770c5ab16f;p=clang Make sure ptrarith_typesize is at least 1 to avoid division by zero git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137234 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index d3332f7b56..d1fa196569 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/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;