From 8ec6dad4498677be1c13bf79a2ce12520fe2fbc7 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 7 Mar 2024 20:35:53 -0500 Subject: [PATCH] LibGfx/TGA: Move a variable closer to its use No behavior change. --- Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp index a3427bf954..5e7aff85df 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TGALoader.cpp @@ -76,9 +76,9 @@ IntSize TGAImageDecoderPlugin::size() static ErrorOr 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(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 {};