This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #31851] Threading crash with closures
[perl5.git] / regcomp.c
index 7587498..2bcb16e 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4983,9 +4983,14 @@ Perl_pregfree(pTHX_ struct regexp *r)
                    (SvTYPE(new_comppad) == SVt_PVAV) ?
                                new_comppad : Null(PAD *)
                );
+               OP_REFCNT_LOCK;
                if (!OpREFCNT_dec((OP_4tree*)r->data->data[n])) {
+                   OP_REFCNT_UNLOCK;
                     op_free((OP_4tree*)r->data->data[n]);
                }
+               else {
+                   OP_REFCNT_UNLOCK;
+               }
 
                PAD_RESTORE_LOCAL(old_comppad);
                SvREFCNT_dec((SV*)new_comppad);