This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
prevent leak of class name from retrieve_hook() on an exception
authorTony Cook <tony@develop-help.com>
Mon, 6 Feb 2017 00:38:10 +0000 (11:38 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 6 Feb 2017 00:38:10 +0000 (11:38 +1100)
commitda1ec2b1b9abdfd956d9c539abf39d908d046304
tree99f4f4bff49a6288528e1353b1d0317ce8c03302
parent3e998ddfb597cfae7bdb460b22e6c50440b1de92
prevent leak of class name from retrieve_hook() on an exception

If supplied with a large class name, retrieve_hook() allocates
buffer for the class name and Safefree()s it on exit path.

Unfortunately this memory leaks if load_module() (or a couple of other
code paths) throw an exception.

So use SAVEFREEPV() to release the memory instead.

==20183== 193 bytes in 1 blocks are definitely lost in loss record 4 of 6
==20183==    at 0x4C28C20: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20183==    by 0x55F85D: Perl_safesysmalloc (util.c:153)
==20183==    by 0x6ACA046: retrieve_hook (Storable.xs:4265)
==20183==    by 0x6AD6D19: retrieve (Storable.xs:6217)
==20183==    by 0x6AD8144: do_retrieve (Storable.xs:6401)
==20183==    by 0x6AD85B7: pretrieve (Storable.xs:6506)
==20183==    by 0x6AD8E14: XS_Storable_pretrieve (Storable.xs:6718)
==20183==    by 0x5C176D: Perl_pp_entersub (pp_hot.c:4227)
==20183==    by 0x55E1C6: Perl_runops_debug (dump.c:2450)
==20183==    by 0x461B79: S_run_body (perl.c:2528)
==20183==    by 0x46115C: perl_run (perl.c:2451)
==20183==    by 0x41F1CD: main (perlmain.c:123)
dist/Storable/Storable.xs