diff --git a/yarp/regexp.c b/yarp/regexp.c index 89eda53142efdf..339438c783d8ad 100644 --- a/yarp/regexp.c +++ b/yarp/regexp.c @@ -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; @@ -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; }