mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-27 01:50:24 +00:00
LibGfx: Use safe version of count_leading_zeroes()
in WOFF parsers
This guards against undefined behavior when zero is given as an argument.
This commit is contained in:
parent
88bd7d83ad
commit
4b5b8fc564
Notes:
sideshowbarker
2024-07-17 00:59:43 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/4b5b8fc564 Pull-request: https://github.com/SerenityOS/serenity/pull/21613
2 changed files with 2 additions and 2 deletions
|
@ -65,7 +65,7 @@ static u16 pow_2_less_than_or_equal(u16 x)
|
|||
{
|
||||
VERIFY(x > 0);
|
||||
VERIFY(x < 32769);
|
||||
return 1 << (sizeof(u16) * 8 - count_leading_zeroes<u16>(x - 1));
|
||||
return 1 << (sizeof(u16) * 8 - count_leading_zeroes_safe<u16>(x - 1));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_file(DeprecatedString path, unsigned int index)
|
||||
|
|
|
@ -113,7 +113,7 @@ static u16 pow_2_less_than_or_equal(u16 x)
|
|||
{
|
||||
VERIFY(x > 0);
|
||||
VERIFY(x < 32769);
|
||||
return 1 << (sizeof(u16) * 8 - count_leading_zeroes<u16>(x - 1));
|
||||
return 1 << (sizeof(u16) * 8 - count_leading_zeroes_safe<u16>(x - 1));
|
||||
}
|
||||
|
||||
enum class TransformationVersion {
|
||||
|
|
Loading…
Reference in a new issue