Skip to content

Commit

Permalink
Fix potential panic (rust-windowing#2755)
Browse files Browse the repository at this point in the history
* Fix potential panic

* Update CHANGELOG.md

* Use checked_div

---------

Co-authored-by: Xiaopeng Li <[email protected]>
  • Loading branch information
xiaopengli89 and xiaopengli89 authored Apr 3, 2023
1 parent fbea75d commit 2486f0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ And please only add new entries to the top of this list, right below the `# Unre
# Unreleased

- Bump MSRV from `1.60` to `1.64`.
- On macOS, fixed potential panic when getting refresh rate.

# 0.28.3

Expand Down
4 changes: 3 additions & 1 deletion src/platform_impl/macos/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ impl MonitorHandle {
return None;
}

Some((time.time_scale as i64 / time.time_value * 1000) as u32)
(time.time_scale as i64)
.checked_div(time.time_value)
.map(|v| (v * 1000) as u32)
}
}

Expand Down

0 comments on commit 2486f0f

Please sign in to comment.