From 474e6db31dcde546041856560c03e15e419fbec3 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Fri, 11 Dec 2015 09:25:06 +0100 Subject: [PATCH] Null terminate wchar string --- src/windows.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index d501d66..c48ae7f 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -187,7 +187,8 @@ pub enum MinifbError { } fn to_wstring(str: &str) -> *const u16 { - let v: Vec = OsStr::new(str).encode_wide().chain(Some(0).into_iter()).collect(); + let mut v: Vec = OsStr::new(str).encode_wide().chain(Some(0).into_iter()).collect(); + v.push(0u16); v.as_ptr() } @@ -203,7 +204,6 @@ impl Window { fn open_window(name: &str, width: usize, height: usize, _: Scale, _: Vsync) -> Option { unsafe { let class_name = to_wstring("minifb_window"); - let class = WNDCLASSW { style: winapi::CS_HREDRAW | winapi::CS_VREDRAW | winapi::CS_OWNDC, lpfnWndProc: Some(wnd_proc),