fix regression in dynamic-linked tls when both main app & libs have tls
[musl] / src / regex / regcomp.c
index 4d80cb1..330de46 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);
@@ -1584,7 +1584,8 @@ tre_add_tags(tre_mem_t mem, tre_stack_t *stack, tre_ast_node_t *tree,
                  {
                    status = tre_add_tag_right(mem, left, tag_left);
                    tnfa->tag_directions[tag_left] = TRE_TAG_MAXIMIZE;
-                   status = tre_add_tag_right(mem, right, tag_right);
+                   if (status == REG_OK)
+                     status = tre_add_tag_right(mem, right, tag_right);
                    tnfa->tag_directions[tag_right] = TRE_TAG_MAXIMIZE;
                  }
                num_tags += 2;
@@ -1700,6 +1701,11 @@ tre_copy_ast(tre_mem_t mem, tre_stack_t *stack, tre_ast_node_t *ast,
                *result = tre_ast_new_literal(mem, min, max, pos);
                if (*result == NULL)
                  status = REG_ESPACE;
+               else {
+                 tre_literal_t *p = (*result)->obj;
+                 p->class = lit->class;
+                 p->neg_classes = lit->neg_classes;
+               }
 
                if (pos > *max_pos)
                  *max_pos = pos;