Skip to content

Commit

Permalink
parse.y: empty here-doc delimiter caused infinite loop; fix #5676
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 24, 2022
1 parent d53a991 commit b4168c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mrbgems/mruby-compiler/core/parse.y
Expand Up @@ -4856,7 +4856,7 @@ parse_string(parser_state *p)
--len;
}
}
if ((len-1 == hinf->term_len) && (strncmp(s, hinf->term, len-1) == 0)) {
if (hinf->term_len > 0 && len-1 == hinf->term_len && strncmp(s, hinf->term, len-1) == 0) {
heredoc_remove_indent(p, hinf);
return tHEREDOC_END;
}
Expand Down
2 changes: 1 addition & 1 deletion mrbgems/mruby-compiler/core/y.tab.c
Expand Up @@ -11087,7 +11087,7 @@ parse_string(parser_state *p)
--len;
}
}
if ((len-1 == hinf->term_len) && (strncmp(s, hinf->term, len-1) == 0)) {
if (hinf->term_len > 0 && len-1 == hinf->term_len && strncmp(s, hinf->term, len-1) == 0) {
heredoc_remove_indent(p, hinf);
return tHEREDOC_END;
}
Expand Down

0 comments on commit b4168c9

Please sign in to comment.