Prechádzať zdrojové kódy

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 :^)
circl 1 rok pred
rodič
commit
a9208a18ca

+ 1 - 1
Userland/Libraries/LibGfx/ImageFormats/BMPLoader.cpp

@@ -1271,7 +1271,7 @@ static ErrorOr<void> 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<int>(width), static_cast<int>(height) }));