diff options
author | Dan Gohman <gohman@apple.com> | 2007-05-17 18:29:01 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2007-05-17 18:29:01 +0000 |
commit | df799afbecee669fb8b86c9590ad2d32d9e3216f (patch) | |
tree | f41ed11b05c86abfbba53a4f2cb1a016678a0d84 | |
parent | e1e9bc7e094b4abe61d4dc173bf7d11784521061 (diff) |
Fix some sporadic segfaults that are triggered when SmallVector's heap
storage lands near the end of the available address space. In the expression
Begin+N > Capacity, the Begin+N was overflowing. Fix this by replacing it
by with an expression that doesn't involve computation of an address
beyond the end of allocated memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37171 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/SmallVector.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index e93177cdcb..1212760305 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -147,7 +147,7 @@ public: destroy_range(Begin+N, End); End = Begin+N; } else if (N > size()) { - if (Begin+N > Capacity) + if (Capacity-Begin < N) grow(N); construct_range(End, Begin+N, T()); End = Begin+N; @@ -159,7 +159,7 @@ public: destroy_range(Begin+N, End); End = Begin+N; } else if (N > size()) { - if (Begin+N > Capacity) + if (Capacity-Begin < N) grow(N); construct_range(End, Begin+N, NV); End = Begin+N; @@ -189,7 +189,7 @@ public: void assign(unsigned NumElts, const T &Elt) { clear(); - if (Begin+NumElts > Capacity) + if (Capacity-Begin < NumElts) grow(NumElts); End = Begin+NumElts; construct_range(Begin, End, Elt); |