You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't have a windows set-up, but I believe the following will crash with OOM (it would be nice for someone to verify that it actually does fail):
use std::os;fnmain(){
os::setenv("test_env","x".repeat(10000));println!("Set ok!");let env = os::getenv("test_env");// will probably crash hereprintln!("Got Some? {}", env.is_some());}
The following patch theoretically fixes it, but causes the try bot to fail:
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 719ed62..7f0e585 100644
--- a/src/libstd/os.rs+++ b/src/libstd/os.rs@@ -112,7 +112,7 @@ pub mod win32 {
let mut done = false;
while !done {
let mut buf = vec::from_elem(n as uint, 0u16);
- let k = f(buf.as_mut_ptr(), TMPBUF_SZ as DWORD);+ let k = f(buf.as_mut_ptr(), n);
if k == (0 as DWORD) {
done = true;
} else if k == n &&
@@ -1498,6 +1498,14 @@ mod tests {
}
#[test]
+ fn test_env_set_get_huge() {+ let n = make_rand_name();+ let s = "x".repeat(10000);+ setenv(n, s);+ assert_eq!(getenv(n), Some(s));+ }++ #[test]
fn test() {
assert!((!Path::new("test-path").is_absolute()));
Failure:
---- os::tests::test_env_set_get_huge stdout ----
task 'os::tests::test_env_set_get_huge' failed at 'assertion failed: end <= self.len()', C:\bot\slave\try-win\build\src\libstd\vec.rs:992
---- run::tests::test_inherit_env stdout ----
task 'run::tests::test_inherit_env' failed at 'assertion failed: k.is_empty() || output.contains(format!("{}={}" , * k , * v))', C:\bot\slave\try-win\build\src\libstd\run.rs:602
On windows, the GetEnvironmentVariable function will return the necessary buffer
size if the buffer provided was too small. This case previously fell through the
checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice`
method.
This adds an extra case for when the return value is >= the buffer size, in
which case we assume the return value as the new buffer size and try again.
Closes#12376
I don't have a windows set-up, but I believe the following will crash with OOM (it would be nice for someone to verify that it actually does fail):
The following patch theoretically fixes it, but causes the try bot to fail:
Failure:
(transmute::<pull, issue>(#12365))
The text was updated successfully, but these errors were encountered: