From cb868cfa41072e08987e1c32f117483445ba197d Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 23 Oct 2021 15:43:59 +0200 Subject: AK+Everywhere: Make Base64 decoding fallible --- Userland/Applications/PixelPaint/Image.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Userland/Applications/PixelPaint') diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 5439c9168e..5796472f3e 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -100,8 +100,10 @@ Result, String> Image::try_create_from_pixel_paint_json(Jso auto bitmap_base64_encoded = layer_object.get("bitmap").as_string(); auto bitmap_data = decode_base64(bitmap_base64_encoded); + if (!bitmap_data.has_value()) + return String { "Base64 decode failed"sv }; - auto bitmap = try_decode_bitmap(bitmap_data); + auto bitmap = try_decode_bitmap(bitmap_data.value()); if (!bitmap) return String { "Layer bitmap decode failed"sv }; -- cgit v1.2.3