Skip to content

Commit f3fbc5b

Browse files
Check for eof in yp_regexp_char_is_eof
1 parent 1764532 commit f3fbc5b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/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)