Skip to content

Commit

Permalink
Fix potential panic (#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
2 people authored and kchibisov committed May 4, 2023
1 parent 64a97c1 commit d37dac8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ And please only add new entries to the top of this list, right below the `# Unre

# Unreleased

- On macOS, fixed potential panic when getting refresh rate.

# 0.28.3

- Fix macOS memory leaks.
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 d37dac8

Please sign in to comment.