diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-01-30 01:24:41 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-30 09:23:18 +0100 |
commit | 4332dfb9640f28ef7daafe340b061d2586d2fc28 (patch) | |
tree | d97d1f41eab9dbc2f01274046138a00d616ec5d7 /AK/Platform.h | |
parent | 648f15395117a6a531415008e38e64e8ca90c837 (diff) | |
download | serenity-4332dfb9640f28ef7daafe340b061d2586d2fc28.zip |
LibGfx: Fix dynamic bitmasks in BMPs
I overlooked a corner case where we might call the built-in ctz() on zero.
Furthermore, the calculation of the shift was wrong and the results were often
unusable.
Both issue were caused by a forgotten 36daeee34ff04f64c933e94a9cdffe9080061fb0.
This time I made sure to look at bmpsuite_files first, and now they look good.
Found by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28985
Diffstat (limited to 'AK/Platform.h')
-rw-r--r-- | AK/Platform.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/AK/Platform.h b/AK/Platform.h index d8d610e295..99fb61c8df 100644 --- a/AK/Platform.h +++ b/AK/Platform.h @@ -81,9 +81,16 @@ ALWAYS_INLINE int count_trailing_zeroes_32(unsigned int val) } return 0; #endif +} + +ALWAYS_INLINE int count_trailing_zeroes_32_safe(unsigned int val) +{ + if (val == 0) + return 32; + return count_trailing_zeroes_32(val); +} #ifdef AK_OS_BSD_GENERIC # define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC # define CLOCK_REALTIME_COARSE CLOCK_REALTIME #endif -} |