From 10757b7787c69776a0f8a23818fd61a4877f52ee Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Wed, 1 Nov 2023 17:42:42 +0000 Subject: [PATCH] LibGfx/TinyVG: Clamp RGBAF32 color values from 0 and 255 --- Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp index ec295a7a14..59d0f7d5cc 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp @@ -154,7 +154,11 @@ static ErrorOr> decode_color_table(Stream& stream, ColorEncoding e auto green = TRY(stream.read_value>()); auto blue = TRY(stream.read_value>()); auto alpha = TRY(stream.read_value>()); - return Color(red * 255, green * 255, blue * 255, alpha * 255); + return Color( + clamp(red * 255.0f, 0.0f, 255.0f), + clamp(green * 255.0f, 0.0f, 255.0f), + clamp(blue * 255.0f, 0.0f, 255.0f), + clamp(alpha * 255.0f, 0.0f, 255.0f)); } default: return Error::from_string_literal("Invalid TinyVG: Bad color encoding");