mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibGfx/TGA: Move a variable closer to its use
No behavior change.
This commit is contained in:
committed by
Andreas Kling
parent
6607757b08
commit
8ec6dad449
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/8ec6dad449 Pull-request: https://github.com/SerenityOS/serenity/pull/23518 Reviewed-by: https://github.com/LucasChollet ✅
@@ -76,9 +76,9 @@ IntSize TGAImageDecoderPlugin::size()
|
||||
|
||||
static ErrorOr<void> ensure_header_validity(TGAHeader const& header, size_t whole_image_stream_size)
|
||||
{
|
||||
auto bytes_remaining = whole_image_stream_size - sizeof(TGAHeader);
|
||||
if ((header.bits_per_pixel % 8) != 0 || header.bits_per_pixel < 8 || header.bits_per_pixel > 32)
|
||||
return Error::from_string_literal("Invalid bit depth");
|
||||
auto bytes_remaining = whole_image_stream_size - sizeof(TGAHeader);
|
||||
if (header.data_type_code == TGADataType::UncompressedRGB && bytes_remaining < static_cast<u64>(header.width) * header.height * (header.bits_per_pixel / 8))
|
||||
return Error::from_string_literal("Not enough data to read an image with the expected size");
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user