summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2023-02-14 22:50:42 +0000
committerPaul Evans <leonerd@leonerd.org.uk>2023-02-17 21:06:16 +0000
commit04c0207ebb3cb7f894b5f5b6320970aabda477a9 (patch)
treeeb8c26eb2998fb14f91d013b9a7a1618b3b8c7f6 /perly.y
parent7da1927c007a205d378f1913ba5dd4027799926e (diff)
downloadperl-04c0207ebb3cb7f894b5f5b6320970aabda477a9.tar.gz
Fix a bunch of memory leaks in feature 'class'
* Free the attrlist OP fragment when applying class or field attribute * Free the OP_PADxV ops we only use to get the pad index out for fieldvar declarations * Add a refcount to the `struct padname_fieldinfo` to keep track of its capture in inner closures so it can be freed at the right time * Free the class-related fields out of HvAUX * Free the actual ObjectFIELDS() array when destroying an object instance * Dup fieldinfo->paramname at sv_dup() time / free it at free time
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y15
1 files changed, 12 insertions, 3 deletions
diff --git a/perly.y b/perly.y
index d2385aa409..381c9f3419 100644
--- a/perly.y
+++ b/perly.y
@@ -1537,11 +1537,20 @@ myterm : PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE
/* "field" declarations */
fieldvar: scalar %prec PERLY_PAREN_OPEN
- { $$ = PadnamelistARRAY(PL_comppad_name)[$scalar->op_targ]; }
+ {
+ $$ = PadnamelistARRAY(PL_comppad_name)[$scalar->op_targ];
+ op_free($scalar);
+ }
| hsh %prec PERLY_PAREN_OPEN
- { $$ = PadnamelistARRAY(PL_comppad_name)[$hsh->op_targ]; }
+ {
+ $$ = PadnamelistARRAY(PL_comppad_name)[$hsh->op_targ];
+ op_free($hsh);
+ }
| ary %prec PERLY_PAREN_OPEN
- { $$ = PadnamelistARRAY(PL_comppad_name)[$ary->op_targ]; }
+ {
+ $$ = PadnamelistARRAY(PL_comppad_name)[$ary->op_targ];
+ op_free($ary);
+ }
;
optfieldattrlist: