This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix minor leak under use feature 'module_true'
authorDavid Mitchell <davem@iabyn.com>
Sat, 9 Dec 2023 10:13:00 +0000 (10:13 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Jan 2024 12:33:02 +0000 (12:33 +0000)
Under PERL_RC_STACK builds, any return value from the module, i.e.
the
    1;
or other final statement value, would leak.

pp_ctl.c

index 1b473fd..43fa6ee 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -5508,11 +5508,8 @@ PP(pp_leaveeval)
         /* make sure that we use a standard return when feature 'module_load'
          * is enabled. Returns from require are problematic (consider what happens
          * when it is called twice) */
-        if (gimme == G_SCALAR) {
-            /* this following is an optimization of POPs()/PUSHs().
-             * and does the same thing with less bookkeeping */
-            *PL_stack_sp = &PL_sv_yes;
-        }
+        if (gimme == G_SCALAR)
+            rpp_replace_1_1(&PL_sv_yes);
         assert(gimme == G_VOID || gimme == G_SCALAR);
         failed = 0;
     }