mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
IPCCompiler: Don't loop endlessly on nameless parameters
Previously, given a malformed IPC call declaration, where a parameter does not have a name, the IPCCompiler would spin endlessly while consuming more and more memory. This is because it parses the parameter type incorrectly (it consumes superfluous characters into the parameter type). An example for such malformed declaration is: tokens_info_result(Vector<GUI::AutocompleteProvider::TokenInfo>) =| As a temporary fix, this adds VERIFY calls that would fail if we're at EOF when parsing parameter names. A real solution would be to parse C++ parameter types correctly. LibCpp's Parser could be used for this task.
This commit is contained in:
parent
308e54bc19
commit
1aa8f73ddb
Notes:
sideshowbarker
2024-07-17 20:02:42 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/1aa8f73ddb6 Pull-request: https://github.com/SerenityOS/serenity/pull/12197
1 changed files with 7 additions and 0 deletions
|
@ -111,6 +111,10 @@ int main(int argc, char** argv)
|
|||
auto parse_parameter = [&](Vector<Parameter>& storage) {
|
||||
for (;;) {
|
||||
Parameter parameter;
|
||||
if (lexer.is_eof()) {
|
||||
warnln("EOF when parsing parameter");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
consume_whitespace();
|
||||
if (lexer.peek() == ')')
|
||||
break;
|
||||
|
@ -128,7 +132,10 @@ int main(int argc, char** argv)
|
|||
consume_whitespace();
|
||||
}
|
||||
}
|
||||
// FIXME: This is not entirely correct. Types can have spaces, for example `HashMap<int, String>`.
|
||||
// Maybe we should use LibCpp::Parser for parsing types.
|
||||
parameter.type = lexer.consume_until([](char ch) { return isspace(ch); });
|
||||
VERIFY(!lexer.is_eof());
|
||||
consume_whitespace();
|
||||
parameter.name = lexer.consume_until([](char ch) { return isspace(ch) || ch == ',' || ch == ')'; });
|
||||
consume_whitespace();
|
||||
|
|
Loading…
Reference in a new issue