Skip to content

Commit 261e366

Browse files
stevenjohnstonematzbot
authored andcommitted
[ruby/yarp] Check for eof in yp_regexp_char_is_eof
ruby/prism@f3fbc5bf9e
1 parent 6ee106f commit 261e366

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

yarp/regexp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ yp_regexp_char_expect(yp_regexp_parser_t *parser, char value) {
5757
// This advances the current token to the next instance of the given character.
5858
static bool
5959
yp_regexp_char_find(yp_regexp_parser_t *parser, char value) {
60+
if (yp_regexp_char_is_eof(parser)) {
61+
return false;
62+
}
6063
const char *end = (const char *) memchr(parser->cursor, value, (size_t) (parser->end - parser->cursor));
6164
if (end == NULL) {
6265
return false;
@@ -383,7 +386,7 @@ yp_regexp_parse_group(yp_regexp_parser_t *parser) {
383386
break;
384387
case '\'': { // named capture group
385388
const char *start = ++parser->cursor;
386-
if (yp_regexp_char_is_eof(parser) || !yp_regexp_char_find(parser, '\'')) {
389+
if (!yp_regexp_char_find(parser, '\'')) {
387390
return false;
388391
}
389392

0 commit comments

Comments
 (0)