Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tl-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ struct tree *parse_term (void) {
}
if (LEX_CHAR ('(')) {
EXPECT ("(");
// EOF or end of valid input check to prevent infinite recursion
if (!curch || parse.pos >= parse.len) {
PARSE_FAIL;
}
PARSE_TRY_PES (parse_expr);
EXPECT (")");
PARSE_OK;
Expand All @@ -559,6 +563,10 @@ struct tree *parse_term (void) {
tree_add_child (T, S);
if (LEX_CHAR ('<')) {
EXPECT ("<");
// EOF check to prevent infinite recursion
if (!curch || parse.pos >= parse.len) {
PARSE_FAIL;
}
while (1) {
PARSE_TRY_PES (parse_expr);
if (LEX_CHAR ('>')) { break; }
Expand Down Expand Up @@ -664,6 +672,10 @@ struct tree *parse_partial_type_app_decl (void) {
PARSE_TRY_PES (parse_boxed_type_ident);
if (LEX_CHAR ('<')) {
EXPECT ("<");
// EOF check to prevent infinite recursion
if (!curch || parse.pos >= parse.len) {
PARSE_FAIL;
}
while (1) {
PARSE_TRY_PES (parse_expr);
if (LEX_CHAR ('>')) { break; }
Expand Down Expand Up @@ -766,6 +778,10 @@ struct tree *parse_args2 (void) {
load_parse (save2);
}
EXPECT ("[");
// EOF check to prevent infinite recursion
if (!curch || parse.pos >= parse.len) {
PARSE_FAIL;
}
while (1) {
if (LEX_CHAR (']')) { break; }
PARSE_TRY_PES (parse_args);
Expand All @@ -777,6 +793,10 @@ struct tree *parse_args2 (void) {
struct tree *parse_args1 (void) {
PARSE_INIT (type_args1);
EXPECT ("(");
// EOF check to prevent infinite recursion
if (!curch || parse.pos >= parse.len) {
PARSE_FAIL;
}
while (1) {
PARSE_TRY_PES (parse_var_ident_opt);
if (LEX_CHAR(':')) { break; }
Expand Down Expand Up @@ -838,6 +858,10 @@ struct tree *parse_result_type (void) {
PARSE_TRY_PES (parse_boxed_type_ident);
if (LEX_CHAR ('<')) {
EXPECT ("<");
// EOF check to prevent infinite recursion
if (!curch || parse.pos >= parse.len) {
PARSE_FAIL;
}
while (1) {
PARSE_TRY_PES (parse_expr);
if (LEX_CHAR ('>')) { break; }
Expand Down