diff --git a/pike.c b/pike.c index 32d7dec..816f29c 100644 --- a/pike.c +++ b/pike.c @@ -507,7 +507,7 @@ int re_comp(rcode *prog, const char *re, int anchored) case SAVE: \ if (sub->ref > 1) { \ for (j = 0; j < subidx; j++) { \ - if (nsubs[j].ref <= 0) { \ + if (!nsubs[j].ref) { \ s1 = &nsubs[j]; \ goto freedsub##nn; \ } \ @@ -583,9 +583,11 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp) npc += *(npc+1) * 2 + 2; goto addthread; case MATCH: + if (matched) + matched->ref = 0; matched = nsub; for(i++; i < clist->n; i++) - clist->t[i].sub->ref--; + clist->t[i].sub->ref = 0; goto BreakFor; } nsub->ref--;