[llvm-commits] CVS: llvm/include/llvm/ADT/SmallVector.h
Dan Gohman
djg at cray.com
Thu May 17 11:29:19 PDT 2007
Changes in directory llvm/include/llvm/ADT:
SmallVector.h updated: 1.28 -> 1.29
---
Log message:
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.
---
Diffs of the changes: (+3 -3)
SmallVector.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
Index: llvm/include/llvm/ADT/SmallVector.h
diff -u llvm/include/llvm/ADT/SmallVector.h:1.28 llvm/include/llvm/ADT/SmallVector.h:1.29
--- llvm/include/llvm/ADT/SmallVector.h:1.28 Wed Apr 18 21:04:09 2007
+++ llvm/include/llvm/ADT/SmallVector.h Thu May 17 13:29:01 2007
@@ -147,7 +147,7 @@
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 @@
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 @@
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);
More information about the llvm-commits
mailing list