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 | 18f169770d9d3f826bad8f1359c8c5770c5ab16f (patch) | |
tree | 63c188843c0a27ffc13efc2910a66808ffdd0cc9 /lib/Sema/SemaChecking.cpp | |
parent | 6b8bc0707f26aa6acfdd80a59b9a3850cafbe387 (diff) |
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
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
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; |