Skip to content

Commit

Permalink
[ruby/yarp] Check for eof in yp_regexp_char_is_eof
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjohnstone authored and matzbot committed Jun 23, 2023
1 parent 6ee106f commit 261e366
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yarp/regexp.c
Expand Up @@ -57,6 +57,9 @@ yp_regexp_char_expect(yp_regexp_parser_t *parser, char value) {
// This advances the current token to the next instance of the given character.
static bool
yp_regexp_char_find(yp_regexp_parser_t *parser, char value) {
if (yp_regexp_char_is_eof(parser)) {
return false;
}
const char *end = (const char *) memchr(parser->cursor, value, (size_t) (parser->end - parser->cursor));
if (end == NULL) {
return false;
Expand Down Expand Up @@ -383,7 +386,7 @@ yp_regexp_parse_group(yp_regexp_parser_t *parser) {
break;
case '\'': { // named capture group
const char *start = ++parser->cursor;
if (yp_regexp_char_is_eof(parser) || !yp_regexp_char_find(parser, '\'')) {
if (!yp_regexp_char_find(parser, '\'')) {
return false;
}

Expand Down

0 comments on commit 261e366

Please sign in to comment.