do not treat \0 as a backref in BRE
[oweals/musl.git] / src / regex / regcomp.c
index 4d80cb1c602ca5d53848c4535db0f1cb88d85aee..dfa9727c5f3601aaa27e864467bd818f72f89127 100644 (file)
@@ -839,7 +839,7 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s)
                        s--;
                        break;
                default:
-                       if (!ere && isdigit(*s)) {
+                       if (!ere && (unsigned)*s-'1' < 9) {
                                /* back reference */
                                int val = *s - '0';
                                node = tre_ast_new_literal(ctx->mem, BACKREF, val, ctx->position);