diff options
author | Dan Gohman <gohman@apple.com> | 2010-07-28 17:11:36 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-07-28 17:11:36 +0000 |
commit | 67d0498d533eedab90e5b6399669c420abbde7c6 (patch) | |
tree | b70ccc4024b6cf6a4ef88c9fb0749f33bc479e89 /lib/Target/TargetData.cpp | |
parent | dc7a235363166a61e81986c534fe11ceb44109fc (diff) |
Do GEP offset calculations with unsigned math rather than signed math
to avoid undefined behavior on overflow, noticed by John Regehr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109594 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r-- | lib/Target/TargetData.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 9b207c1f28..65f514c264 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -625,7 +625,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices, // Get the array index and the size of each array element. if (int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue()) - Result += arrayIdx * (int64_t)getTypeAllocSize(Ty); + Result += (uint64_t)arrayIdx * getTypeAllocSize(Ty); } } |