From a9208a18ca39806d8e50df2ad214fe15e1ac3aff Mon Sep 17 00:00:00 2001 From: circl Date: Wed, 18 Oct 2023 19:56:09 +0200 Subject: [PATCH] LibGfx/BMPLoader: Make sure height passed to Gfx::Bitmap is positive BMP files encode the direction of the rows with the sign of the height. Our BMP decoder already makes all the proper checks, however when constructing the Gfx::Bitmap, didn't actually make the height positive. Boog neutralized :^) --- Userland/Libraries/LibGfx/ImageFormats/BMPLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/BMPLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/BMPLoader.cpp index c9d37f73e6..a48d7fdf27 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/BMPLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/BMPLoader.cpp @@ -1271,7 +1271,7 @@ static ErrorOr decode_bmp_pixel_data(BMPLoadingContext& context) } u32 const width = abs(context.dib.core.width); - u32 const height = !context.is_included_in_ico ? context.dib.core.height : (context.dib.core.height / 2); + u32 const height = !context.is_included_in_ico ? abs(context.dib.core.height) : (abs(context.dib.core.height) / 2); context.bitmap = TRY(Bitmap::create(format, { static_cast(width), static_cast(height) }));