Fix potential panic (#2755)

* Fix potential panic

* Update CHANGELOG.md

* Use checked_div

---------

Co-authored-by: Xiaopeng Li <lixiaopeng.jetspark@bytedance.com>
This commit is contained in:
Xiaopeng Li 2023-04-04 02:46:09 +08:00 committed by GitHub
parent fbea75d31f
commit 2486f0f1a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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

View file

@ -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)
}
}