Переглянути джерело

LibGfx/WebPLoader: Diagnose ICCP flag / ICCP chunk presence mismatch

If this turns out to be too strict in practice, we can replace it with
a dbgln() with the same message, but with with ", ignoring header."
tacked on at the end.
Nico Weber 1 рік тому
батько
коміт
25e2e17218

+ 5 - 0
Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp

@@ -445,6 +445,11 @@ static ErrorOr<void> decode_webp_extended(WebPLoadingContext& context, ReadonlyB
         return Error::from_string_literal("WebPImageDecoderPlugin: ICCP chunk is after image data");
     }
 
+    if (context.iccp_chunk.has_value() && !context.vp8x_header.has_icc)
+        return Error::from_string_literal("WebPImageDecoderPlugin: ICCP chunk present, but VP8X header claims no ICC profile");
+    if (!context.iccp_chunk.has_value() && context.vp8x_header.has_icc)
+        return Error::from_string_literal("WebPImageDecoderPlugin: VP8X header claims ICC profile, but no ICCP chunk present");
+
     context.state = WebPLoadingContext::State::ChunksDecoded;
     return {};
 }