mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx: Fix sign-compare compile error in TGALoader
I'm not sure why this isn't caught on other people's setups or CI, but when building on NixOS it fails with: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
This commit is contained in:
parent
533f2a4980
commit
10575fea9f
Notes:
sideshowbarker
2024-07-17 04:10:16 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/10575fea9f Pull-request: https://github.com/SerenityOS/serenity/pull/17523 Reviewed-by: https://github.com/gmta
1 changed files with 4 additions and 2 deletions
|
@ -209,7 +209,8 @@ bool TGAImageDecoderPlugin::decode_tga_header()
|
|||
|
||||
auto bytes_remaining = reader->data().size() - reader->index();
|
||||
|
||||
if (m_context->header.data_type_code == TGADataType::UncompressedRGB && bytes_remaining < (m_context->header.width * m_context->header.height * (m_context->header.bits_per_pixel / 8)))
|
||||
// FIXME: Check for multiplication overflow!
|
||||
if (m_context->header.data_type_code == TGADataType::UncompressedRGB && bytes_remaining < static_cast<size_t>(m_context->header.width * m_context->header.height * (m_context->header.bits_per_pixel / 8)))
|
||||
return false;
|
||||
|
||||
if (m_context->header.bits_per_pixel < 8 || m_context->header.bits_per_pixel > 32)
|
||||
|
@ -228,7 +229,8 @@ ErrorOr<bool> TGAImageDecoderPlugin::validate_before_create(ReadonlyBytes data)
|
|||
if (data.size() < sizeof(TGAHeader))
|
||||
return false;
|
||||
TGAHeader const& header = *reinterpret_cast<TGAHeader const*>(data.data());
|
||||
if (header.data_type_code == TGADataType::UncompressedRGB && data.size() < (header.width * header.height * (header.bits_per_pixel / 8)))
|
||||
// FIXME: Check for multiplication overflow!
|
||||
if (header.data_type_code == TGADataType::UncompressedRGB && data.size() < static_cast<size_t>(header.width * header.height * (header.bits_per_pixel / 8)))
|
||||
return false;
|
||||
if (header.bits_per_pixel < 8 || header.bits_per_pixel > 32)
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue