From 33db6de8d40e780f588c82391843e9f44e65492d Mon Sep 17 00:00:00 2001 From: paxcut Date: Sat, 30 May 2026 14:08:50 -0700 Subject: [PATCH] fix: imhex uses all memory It appears that my attempt to patch all possible places that could create an infinite loop failed to notice cases like namespace parsing and possibly others. Being unable to guarantee that the error alone will stop the loops I am forced to also make sure that every result of the loop advances the cursor at least one token. I can't really say if this is going to finally fix this problem but just as before, all tests I ran showed that it is indeed the case. --- lib/source/pl/core/parser.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/source/pl/core/parser.cpp b/lib/source/pl/core/parser.cpp index 84399e79..5907f3ee 100644 --- a/lib/source/pl/core/parser.cpp +++ b/lib/source/pl/core/parser.cpp @@ -977,6 +977,7 @@ namespace pl::core { errorHere("Invalid {} found in function.", getFormattedToken(0)); else errorHere("Invalid function statement."); + next(); return nullptr; } @@ -1938,11 +1939,11 @@ namespace pl::core { return parseTryCatchStatement([this] { return parseMember(); }); else if (oneOf(tkn::Keyword::Return, tkn::Keyword::Break, tkn::Keyword::Continue)) member = parseFunctionControlFlowStatement(); - else if (m_curr[0].type == Token::Type::Keyword) { - errorHere("Invalid {} found in custom type.", getFormattedToken(0)); - return nullptr; - } else { - errorHere("Invalid struct member definition."); + else { + if (m_curr[0].type == Token::Type::Keyword) + errorHere("Invalid {} found in custom type.", getFormattedToken(0)); + else + errorHere("Invalid struct member definition."); next(); return nullptr; }