diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-03-12 20:59:42 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-24 10:56:58 +0100 |
commit | 74f893e9f41e4aa703afa8b47d816e217e908b4e (patch) | |
tree | 02e2a8eba0e3d4e564c106b6ba3bc47e0fa740f4 /Userland/Libraries/LibGfx | |
parent | 964172754e0fdaa4ee2cd48e732410981b28555c (diff) | |
download | serenity-74f893e9f41e4aa703afa8b47d816e217e908b4e.zip |
LibGfx/PortableFormat: Make `read_comment` return an `ErrorOr`
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h b/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h index f9b65b67e9..fe9dacc711 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h +++ b/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h @@ -53,7 +53,7 @@ static inline ErrorOr<u16> read_number(Streamer& streamer) } template<typename TContext> -static bool read_comment([[maybe_unused]] TContext& context, Streamer& streamer) +static ErrorOr<void> read_comment([[maybe_unused]] TContext& context, Streamer& streamer) { bool is_first_char = true; u8 byte {}; @@ -61,14 +61,14 @@ static bool read_comment([[maybe_unused]] TContext& context, Streamer& streamer) while (streamer.read(byte)) { if (is_first_char) { if (byte != '#') - return false; + return Error::from_string_literal("Can't read comment from stream"); is_first_char = false; } else if (byte == '\t' || byte == '\n') { break; } } - return true; + return {}; } template<typename TContext> @@ -119,7 +119,8 @@ static bool read_whitespace(TContext& context, Streamer& streamer) exist = true; } else if (byte == '#') { streamer.step_back(); - read_comment(context, streamer); + if (read_comment(context, streamer).is_error()) + return false; } else { streamer.step_back(); return exist; |