mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-19 04:29:21 +00:00
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
This commit is contained in:
parent
e1e9bc7e09
commit
df799afbec
@ -147,7 +147,7 @@ public:
|
|||||||
destroy_range(Begin+N, End);
|
destroy_range(Begin+N, End);
|
||||||
End = Begin+N;
|
End = Begin+N;
|
||||||
} else if (N > size()) {
|
} else if (N > size()) {
|
||||||
if (Begin+N > Capacity)
|
if (Capacity-Begin < N)
|
||||||
grow(N);
|
grow(N);
|
||||||
construct_range(End, Begin+N, T());
|
construct_range(End, Begin+N, T());
|
||||||
End = Begin+N;
|
End = Begin+N;
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
destroy_range(Begin+N, End);
|
destroy_range(Begin+N, End);
|
||||||
End = Begin+N;
|
End = Begin+N;
|
||||||
} else if (N > size()) {
|
} else if (N > size()) {
|
||||||
if (Begin+N > Capacity)
|
if (Capacity-Begin < N)
|
||||||
grow(N);
|
grow(N);
|
||||||
construct_range(End, Begin+N, NV);
|
construct_range(End, Begin+N, NV);
|
||||||
End = Begin+N;
|
End = Begin+N;
|
||||||
@ -189,7 +189,7 @@ public:
|
|||||||
|
|
||||||
void assign(unsigned NumElts, const T &Elt) {
|
void assign(unsigned NumElts, const T &Elt) {
|
||||||
clear();
|
clear();
|
||||||
if (Begin+NumElts > Capacity)
|
if (Capacity-Begin < NumElts)
|
||||||
grow(NumElts);
|
grow(NumElts);
|
||||||
End = Begin+NumElts;
|
End = Begin+NumElts;
|
||||||
construct_range(Begin, End, Elt);
|
construct_range(Begin, End, Elt);
|
||||||
|
Loading…
Reference in New Issue
Block a user