This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
DosGlob: Don’t leak when caller’s op tree is freed
authorFather Chrysostomos <sprout@cpan.org>
Tue, 11 Dec 2012 00:43:12 +0000 (16:43 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 11 Dec 2012 13:37:32 +0000 (05:37 -0800)
commit7fddb138e6bbaa0efbb2096d3d3cc5a0ee34d546
tree0d7a28ea63455d2c72d2a66d2e6dbbf9bac1d4a2
parenta21a75c8b50f9fa1a0642bac43a6e51ed8083f0f
DosGlob: Don’t leak when caller’s op tree is freed

File::DosGlob keeps its own hash of arrays of file names.  Each array
corresponds to one call site.  When iteration finishes, it deletes
the array.  But if iteration never finishes, and the op at the call
site is freed, the array remains.  So eval "scalar<*>" will cause a
memory leak under the scope of ‘use File::DosGlob "glob"’.

We already have a mechanism for hooking the freeing of ops.  So
File::DosGlob can use that.

This is similar to 11ddfebc6e which fixed up File::Glob, but that com-
mit mistakenly used a C static for storing the old hook, even though
PL_opfreehook is an interpreter variable, not a global.  (The next
commit will fix that.)
ext/File-DosGlob/DosGlob.xs
ext/File-DosGlob/lib/File/DosGlob.pm
ext/File-DosGlob/t/DosGlob.t