-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check value is in range before casting from double to uint32_t #1828
Check value is in range before casting from double to uint32_t #1828
Conversation
…oid undefined behavior.
I wonder if we should use nearbyint for the rounding on the main branch. (Can't use it on 0.27-maintenance because it's a C++11 feature.) C++11 also has an |
This pull request introduces 1 alert when merging 1455cc8 into b364b1d - view on LGTM.com new alerts:
|
👍 for using C++11 features in Any reason to use |
Co-authored-by: Christoph Hasse <hassec@users.noreply.github.com>
@hassec: you're right, |
Check value is in range before casting from double to uint32_t (backport #1828)
Fixes: #1827
The
static_cast<long>
can cause a UBSAN failure if the value oftmp
is out of range. It was also incorrect to cast tolong
, because the type ofur.second
isuint32_t
.