op.c:opslab_force_free: Make paranoid code reflect reality
authorFather Chrysostomos <sprout@cpan.org>
Mon, 5 Nov 2012 02:21:34 +0000 (18:21 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 5 Nov 2012 06:45:35 +0000 (22:45 -0800)
When opslab_force_free is called, the CV still has a reference count
on the slab.  In fact, we don’t even bother lowering it if all goes
well, but simply free the slab with the reference count set to 1.
So the paranoid code that increments the reference count before free-
ing an op is not necessary.  Also, the shortcut out of the loop
was never triggered, as it was checking for a reference count of 0,
rather than 1.

op.c

diff --git a/op.c b/op.c
index 488665f..93b71bd 100644 (file)
--- a/op.c
+++ b/op.c
@@ -380,9 +380,8 @@ Perl_opslab_force_free(pTHX_ OPSLAB *slab)
                 )
            ) {
                assert(slot->opslot_op.op_slabbed);
-               slab->opslab_refcnt++; /* op_free may free slab */
                op_free(&slot->opslot_op);
-               if (!--slab->opslab_refcnt) goto free;
+               if (slab->opslab_refcnt == 1) goto free;
            }
        }
     } while ((slab2 = slab2->opslab_next));