From 3752facfbc965fb557b269d7e5c5109595163b6a Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Mon, 17 Jul 2023 12:38:57 -0400 Subject: [PATCH] LibGfx: Don't assume that image decoder plugin creation succeeds An image with an incorrect header should fail at this step, so we have to handle that without crashing. This should have been done in 7b72bf29. --- Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp index 995937f28b..d85c79e1f2 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp @@ -75,9 +75,11 @@ static OwnPtr probe_and_sniff_for_appropriate_plugin_with_kn auto validation_result = plugin.validate_before_create(bytes).release_value_but_fixme_should_propagate_errors(); if (!validation_result) continue; - auto plugin_decoder = plugin.create(bytes).release_value_but_fixme_should_propagate_errors(); - if (!plugin_decoder->initialize().is_error()) - return plugin_decoder; + auto plugin_decoder = plugin.create(bytes); + if (!plugin_decoder.is_error()) { + if (!plugin_decoder.value()->initialize().is_error()) + return plugin_decoder.release_value(); + } } return {}; }