Skip to content

Commit dc3862b

Browse files
committed
This was unsafe, and will probably leak.
1 parent 3b9848b commit dc3862b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/libcore/vec.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,21 @@ fn shift<T>(&v: [T]) -> T {
379379
v <-> vv;
380380

381381
unsafe {
382-
let vv = unsafe::to_ptr(vv);
383-
let r <- *vv;
384-
385-
for uint::range(1u, ln) {|i|
386-
// FIXME: this isn't legal, per se...
387-
let r <- *ptr::offset(vv, i);
388-
push(v, r);
382+
let mut rr;
383+
{
384+
let vv = unsafe::to_ptr(vv);
385+
let mut r <- *vv;
386+
387+
for uint::range(1u, ln) {|i|
388+
// FIXME: this isn't legal, per se...
389+
let r <- *ptr::offset(vv, i);
390+
push(v, r);
391+
}
392+
rr <- r;
389393
}
394+
unsafe::set_len(vv, 0u);
390395

391-
r
396+
rr
392397
}
393398
}
394399

0 commit comments

Comments
 (0)