LibGfx/PortableFormat: Don't accept comments that don't start with #

This commit is contained in:
Lucas CHOLLET 2023-03-12 20:58:55 -04:00 committed by Andreas Kling
commit 964172754e
Notes: sideshowbarker 2024-07-16 23:44:30 +09:00

View file

@ -55,18 +55,20 @@ static inline ErrorOr<u16> read_number(Streamer& streamer)
template<typename TContext> template<typename TContext>
static bool read_comment([[maybe_unused]] TContext& context, Streamer& streamer) static bool read_comment([[maybe_unused]] TContext& context, Streamer& streamer)
{ {
bool exist = false; bool is_first_char = true;
u8 byte {}; u8 byte {};
while (streamer.read(byte)) { while (streamer.read(byte)) {
if (byte == '#') { if (is_first_char) {
exist = true; if (byte != '#')
return false;
is_first_char = false;
} else if (byte == '\t' || byte == '\n') { } else if (byte == '\t' || byte == '\n') {
return exist; break;
} }
} }
return exist; return true;
} }
template<typename TContext> template<typename TContext>