This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix leak in do { ... } while 0
authorDavid Mitchell <davem@iabyn.com>
Fri, 12 Apr 2019 13:52:27 +0000 (14:52 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 12 Apr 2019 14:58:04 +0000 (15:58 +0100)
The op tree for

    do X while 0

is simplified to

    X

but the const OP for the '0' wasn't being freed and so leaked.

op.c

diff --git a/op.c b/op.c
index 98633b9..d896300 100644 (file)
--- a/op.c
+++ b/op.c
@@ -8649,7 +8649,11 @@ Perl_newLOOPOP(pTHX_ I32 flags, I32 debuggable, OP *expr, OP *block)
           ))
            /* Return the block now, so that S_new_logop does not try to
               fold it away. */
-           return block;       /* do {} while 0 does once */
+        {
+            op_free(expr);
+            return block;      /* do {} while 0 does once */
+        }
+
        if (expr->op_type == OP_READLINE
            || expr->op_type == OP_READDIR
            || expr->op_type == OP_GLOB