This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_op_sibling_splice(): update OPf_KIDS
authorDavid Mitchell <davem@iabyn.com>
Thu, 30 Oct 2014 10:28:06 +0000 (10:28 +0000)
committerDavid Mitchell <davem@iabyn.com>
Sun, 7 Dec 2014 09:07:30 +0000 (09:07 +0000)
Previously this function didn't update OPf_KIDS when altering the
children. This was only safe as long as the count of kids didn't transition
between 0 and !0.

op.c

diff --git a/op.c b/op.c
index a045e55..a95c6f4 100644 (file)
--- a/op.c
+++ b/op.c
@@ -1190,8 +1190,13 @@ Perl_op_sibling_splice(OP *parent, OP *start, int del_count, OP* insert)
         OP_SIBLING_set(start, insert);
         start->op_lastsib = insert ? 0 : 1;
     }
-    else
+    else {
         cLISTOPx(parent)->op_first = insert;
+        if (insert)
+            parent->op_flags |= OPf_KIDS;
+        else
+            parent->op_flags &= ~OPf_KIDS;
+    }
 
     if (!rest) {
         /* update op_last etc */