From 3b3d7021e4a2bccace8816bb24eec33eac09c9f2 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 25 Sep 2014 13:01:32 -0700 Subject: [PATCH] Add test for #13259. Closes #13259 and #14742 --- .../run-pass/issue-13259-windows-tcb-trash.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/run-pass/issue-13259-windows-tcb-trash.rs 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 index 0000000000000..94953730df896 --- /dev/null +++ b/src/test/run-pass/issue-13259-windows-tcb-trash.rs @@ -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