Skip to content

Commit

Permalink
Throw if an invalid handle passed to CloseHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
YohDeadfall committed Nov 6, 2024
1 parent bfc5234 commit 37900dc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/shims/windows/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let handle = this.read_scalar(handle_op)?;
let ret = match Handle::from_scalar(handle, this)? {
Some(Handle::Thread(thread)) => {
match this.thread_id_try_from(thread) {
Ok(thread) => {
this.detach_thread(thread, /*allow_terminated_joined*/ true)?;
this.eval_windows("c", "TRUE")
}
Err(_) => {
this.set_last_error(this.eval_windows("c", "ERROR_INVALID_HANDLE"))?;
this.eval_windows("c", "FALSE")
}
if let Ok(thread) = this.thread_id_try_from(thread) {
this.detach_thread(thread, /*allow_terminated_joined*/ true)?;
this.eval_windows("c", "TRUE")
} else {
this.invalid_handle("CloseHandle")?
}
}
_ => this.invalid_handle("CloseHandle")?,
Expand Down

0 comments on commit 37900dc

Please sign in to comment.