Skip to content

Commit 102109f

Browse files
committed
---
yaml --- r: 89786 b: refs/heads/master c: 0966ec0 h: refs/heads/master v: v3
1 parent 8e10345 commit 102109f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1f192430956704ddf263aba0cfb5b8856c547beb
2+
refs/heads/master: 0966ec01dcb0ff90e6d483706820794ef8e16c2e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8

trunk/src/libstd/vec.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ pub fn with_capacity<T>(capacity: uint) -> ~[T] {
186186
vec
187187
} else {
188188
let alloc = capacity * mem::nonzero_size_of::<T>();
189-
let ptr = malloc_raw(alloc + mem::size_of::<Vec<()>>()) as *mut Vec<()>;
189+
let size = alloc + mem::size_of::<Vec<()>>();
190+
if alloc / mem::nonzero_size_of::<T>() != capacity || size < alloc {
191+
fail!("vector size is too large: {}", capacity);
192+
}
193+
let ptr = malloc_raw(size) as *mut Vec<()>;
190194
(*ptr).alloc = alloc;
191195
(*ptr).fill = 0;
192196
cast::transmute(ptr)

0 commit comments

Comments
 (0)