Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 59b78810094a841d3440b02afec38a629732062c https://github.com/Perl/perl5/commit/59b78810094a841d3440b02afec38a629732062c Author: Tony Cook <t...@develop-help.com> Date: 2023-07-25 (Tue, 25 Jul 2023)
Changed paths: M pad.c M t/op/lexsub.t Log Message: ----------- cv_undef_flags: there's nothing to clean up for our subs in cloned pads Fixes #21067 When an instance of a closure is created, the pad entries for the cloned sub are copied (S_clone_sv_pad()) from either the prototype sub (for lexicals belonging to the sub) or from the context (for lexicals from outside the sub). This doesn't happen for our variables, instead the cloned sub has these pad entries set to NULL. This isn't an issue at runtime since references to lexical our sub/variables are compiled into GV or GVSV ops. cv_undef_flags() assumed this these entries were non-NULL for all lexical subs. Fix by checking if the entry is an our sub and the CV being freed is a clone, if so, skip the accesses to the NULL pad entry. Added an assert to the new branch to ensure any changes in the above results in an early failure here and hopefully a fix.