about summary refs log tree commit diff
path: root/src/libstd/vec.rs
diff options
context:
space:
mode:
authorblake2-ppc <blake2-ppc>2013-09-12 05:00:25 +0200
committerblake2-ppc <blake2-ppc>2013-09-17 02:48:00 +0200
commite211888407db32fcec53f4fa9eb84acdbdf59f87 (patch)
tree74b7b8aae3027586895cb1717c9a93eb751fbcd0 /src/libstd/vec.rs
parent6e538edea2557018c3c8eae41aacf6cdf6370a4d (diff)
downloadrust-e211888407db32fcec53f4fa9eb84acdbdf59f87.tar.gz
rust-e211888407db32fcec53f4fa9eb84acdbdf59f87.zip
std::at_vec: Fix segfault on overflow when resizing ~[@T]
Easy to reproduce:

    let mut v = ~[@1];
    v.resize(-1);  // success a.k.a silent failure
    v.push(@2); // segfault
Diffstat (limited to 'src/libstd/vec.rs')
-rw-r--r--src/libstd/vec.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index b7274d58e1b..9fc0eaf72b1 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -3660,6 +3660,14 @@ mod tests {
     }
 
     #[test]
+    #[should_fail]
+    fn test_overflow_does_not_cause_segfault_managed() {
+        let mut v = ~[@1];
+        v.reserve(-1);
+        v.push(@2);
+    }
+
+    #[test]
     fn test_mut_split() {
         let mut values = [1u8,2,3,4,5];
         {