HLE: guard dialog commands before initialization

(cherry picked from commit 9ccb83c00a9b0ee5121e4a9b2f6c0ee223630c84)
This commit is contained in:
Calvix2k authored and local committed 2026-11-25 01:03:02 -06:00
1 parent 200bde46a6
commit 241a70924a
1 file changed
+18 -1
+18 -1
View File
@@ -227,7 +227,11 @@ mod dialog {
0 // focus set here
}
wm::WM_COMMAND => {
let entry = &mut *(wm::GetWindowLongPtrW(dialog, wm::GWLP_USERDATA) as *mut Entry);
let user_data = wm::GetWindowLongPtrW(dialog, wm::GWLP_USERDATA);
if user_data == 0 {
return 0;
}
let entry = &mut *(user_data as *mut Entry);
match (wparam & 0xffff) as i32 {
wm::IDOK => {
let mut buffer = vec![0u16; wm::GetWindowTextLengthW(edit) as usize + 1];
@@ -246,6 +250,19 @@ mod dialog {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn command_before_init_is_ignored() {
assert_eq!(
procedure(std::ptr::null_mut(), wm::WM_COMMAND, wm::IDOK as WPARAM, 0,),
0
);
}
}
}
static VTABLE: Methods<20> = Methods([