[pve-devel] [PATCH common v2 1/3] JSONSchema: add support for array parameter in api calls, cli and config

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Jun 6 14:05:22 CEST 2023


On Tue, Jun 06, 2023 at 12:45:57PM +0200, Thomas Lamprecht wrote:
> Am 06/06/2023 um 11:41 schrieb Dominik Csapak:
> >>>   +my $untaint_recursive;
> >>
> >> I got flash backs w.r.t. refcount cycles here keeping all variables, and thus memory
> >> inside the body alive forever, don't we need a weaken?
> >>
> >> E.g., like we had to do in PVE::Status::Graphite's assemble.
> > 
> > mhmm isn't that because there we use variables from outside the
> > function? here we only use the parameters themselves
> 
> I'm not 100% sure about the details, but since then, seeing something like
> this pattern triggers my cycle instincts, I'd like to have that checked out
> closely.

I *do* prefer `my sub` these days.
However, for recursive subs you need to `use feature 'current_sub'` to
avoid ... well... leaks ;-)

So:

    my sub untaint_recursive : prototype($) {
        use feature 'current_sub';

        my ($arg) = @_;

        ...
        # For recursion:
        __SUB__->($stuff);
        ...
    }

Given that this function shouldn't be leaky, you could keep it, or even
pre-declare the sub to allow recursion:

    my sub untaint_recursive : prototype($);
    sub untaint_recursive : prototype($) {
        <regular code>
    }

however, `perlsub` explicitly states that this, too, can leak ;-)





More information about the pve-devel mailing list