diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-10-24 09:37:37 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-10-24 14:07:31 +0200 |
commit | 635a0b426e0ab47ec136af7d110354db862c59fa (patch) | |
tree | 7ec9f177de247c27cb4d2335cf0992a66247d616 /o3tl | |
parent | 87aef8ff9fa55dc8b51c6eb8ae07ab34236503c1 (diff) |
Fix MulDivSaturate to avoid overflow
Thanks to Caolan
https://gerrit.libreoffice.org/c/core/+/110839/comments/5c47cab2_b0523546
> oss-fuzz has come up with a case of n 9223372036854775807 m 72 d 127
>
> include/o3tl/unit_conversion.hxx:105:28: runtime error: signed integer
> overflow: 9223372036854775807 + 63 cannot be represented in type 'long'
Change-Id: I0fe26f6c854a90cf577a60528d15f3da5471b914
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141711
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'o3tl')
-rw-r--r-- | o3tl/qa/test-unit_conversion.cxx | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/o3tl/qa/test-unit_conversion.cxx b/o3tl/qa/test-unit_conversion.cxx index 8b2c05c54549..d140f1da7ec6 100644 --- a/o3tl/qa/test-unit_conversion.cxx +++ b/o3tl/qa/test-unit_conversion.cxx @@ -878,4 +878,6 @@ static_assert(o3tl::toTwips(20, o3tl::Length::mm) == 1134); // 847 100thmm used to represent 24pt static_assert(o3tl::convert(24, o3tl::Length::pt, o3tl::Length::mm100) == 847); +static_assert(o3tl::convertSaturate(SAL_MAX_INT64, 72, 127) == 5228998320106644552); // no overflow + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |