1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

LibGfx+Fuzz: Convert ImageDecoder::initialize to ErrorOr

This prevents callers from accidentally discarding the result of
initialize(), which was the root cause of this OSS Fuzz bug:

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=55896&q=label%3AProj-serenity&sort=summary
This commit is contained in:
Ben Wiederhake 2023-05-07 19:27:07 +02:00 committed by Sam Atkins
parent a84e64ed22
commit da394abe04
37 changed files with 125 additions and 105 deletions

View file

@ -629,7 +629,7 @@ WebPImageDecoderPlugin::WebPImageDecoderPlugin(ReadonlyBytes data, OwnPtr<WebPLo
WebPImageDecoderPlugin::~WebPImageDecoderPlugin() = default;
bool WebPImageDecoderPlugin::set_error(ErrorOr<void>&& error_or)
bool WebPImageDecoderPlugin::set_error(ErrorOr<void> const& error_or)
{
if (error_or.is_error()) {
m_context->state = WebPLoadingContext::State::Error;
@ -664,9 +664,11 @@ bool WebPImageDecoderPlugin::set_nonvolatile(bool& was_purged)
return m_context->bitmap->set_nonvolatile(was_purged);
}
bool WebPImageDecoderPlugin::initialize()
ErrorOr<void> WebPImageDecoderPlugin::initialize()
{
return !set_error(decode_webp_header(*m_context));
auto header_okay_or_error = decode_webp_header(*m_context);
set_error(header_okay_or_error);
return header_okay_or_error;
}
bool WebPImageDecoderPlugin::sniff(ReadonlyBytes data)