]> git.lizzy.rs Git - rust.git/commitdiff
Add test for #13259. Closes #13259 and #14742
authorBrian Anderson <banderson@mozilla.com>
Thu, 25 Sep 2014 20:01:32 +0000 (13:01 -0700)
committerBrian Anderson <banderson@mozilla.com>
Fri, 26 Sep 2014 17:17:03 +0000 (10:17 -0700)
src/test/run-pass/issue-13259-windows-tcb-trash.rs [new file with mode: 0644]

diff --git a/src/test/run-pass/issue-13259-windows-tcb-trash.rs b/src/test/run-pass/issue-13259-windows-tcb-trash.rs
new file mode 100644 (file)
index 0000000..9495373
--- /dev/null
@@ -0,0 +1,28 @@
+extern crate libc;
+use libc::{c_void, LPVOID, DWORD};
+use libc::types::os::arch::extra::LPWSTR;
+
+extern "system" {
+    fn FormatMessageW(flags: DWORD,
+                      lpSrc: LPVOID,
+                      msgId: DWORD,
+                      langId: DWORD,
+                      buf: LPWSTR,
+                      nsize: DWORD,
+                      args: *const c_void)
+                      -> DWORD;
+}
+
+fn test() {
+    let mut buf: [u16, ..50] = [0, ..50];
+    let ret = unsafe {
+        FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
+                       buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
+    };
+    // On some 32-bit Windowses (Win7-8 at least) this will fail with segmented
+    // stacks taking control of pvArbitrary
+    assert!(ret != 0);
+}
+fn main() {
+    test()
+}
\ No newline at end of file