summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/regcomp.c b/regcomp.c
index 97e81bc728..7b4d647995 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4967,6 +4967,7 @@ Perl_pregfree(pTHX_ struct regexp *r)
int n = r->data->count;
PAD* new_comppad = NULL;
PAD* old_comppad;
+ PADOFFSET refcnt;
while (--n >= 0) {
/* If you add a ->what type here, update the comment in regcomp.h */
@@ -4989,13 +4990,10 @@ Perl_pregfree(pTHX_ struct regexp *r)
new_comppad : Null(PAD *)
);
OP_REFCNT_LOCK;
- if (!OpREFCNT_dec((OP_4tree*)r->data->data[n])) {
- OP_REFCNT_UNLOCK;
+ refcnt = OpREFCNT_dec((OP_4tree*)r->data->data[n]);
+ OP_REFCNT_UNLOCK;
+ if (!refcnt)
op_free((OP_4tree*)r->data->data[n]);
- }
- else {
- OP_REFCNT_UNLOCK;
- }
PAD_RESTORE_LOCAL(old_comppad);
SvREFCNT_dec((SV*)new_comppad);