Skip to content

Commit

Permalink
fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
skaji committed Oct 9, 2023
1 parent 413ccf2 commit 831f704
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
prove: /usr/local/bin/prove
cpm-option: ''
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: perl -V
run: ${{ matrix.perl }} -V
- name: Install Dependencies
run: curl -fsSL --compressed https://raw.githubusercontent.com/skaji/cpm/main/cpm | ${{ matrix.perl }} - install -g ${{ matrix.cpm-option }} --with-develop --with-recommends --show-build-log-on-failure
- name: Build
run: ${{ matrix.perl }} Makefile.PL && make
- name: Run Tests
run: make test
run: ${{ matrix.prove }} -b t xt
5 changes: 2 additions & 3 deletions FSEvents.xs
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,11 @@ PPCODE:

fh = fdopen( respipe_read_copy, "r" );

glob = (GV *) SvREFCNT_inc(newGVgen("Mac::FSEvents"));
glob = (GV *) newGVgen("Mac::FSEvents");
fp = PerlIO_importFILE(fh, 0);
do_open(glob, "+<&", 3, FALSE, 0, 0, fp);

XPUSHs( sv_2mortal( newRV((SV *) glob) ) );
SvREFCNT_dec(glob);
XPUSHs( sv_2mortal( newRV_noinc((SV *) glob) ) );
return;
handle_errors:
if(self->respipe[0] >= 0) {
Expand Down
3 changes: 3 additions & 0 deletions cpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ prereqs:
test:
requires:
Test::More: { version: '0.99' }
develop:
requires:
Test::LeakTrace:
1 change: 1 addition & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ match = ^(xt|author|maint|example|eg)/
[GitHubREADME::Badge]
badges = github_actions/test.yml
[Prereqs::From::cpmfile]
phases = configure,build,runtime,test
[MetaJSON]
[Git::Contributors]
[License]
Expand Down
14 changes: 14 additions & 0 deletions xt/01_leak.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use strict;
use warnings;
use Test::More;

use Mac::FSEvents;
use Test::LeakTrace;

no_leaks_ok {
my $fs = Mac::FSEvents->new(path => "/");
my $fh = $fs->watch;
$fs->stop;
};

done_testing;

0 comments on commit 831f704

Please sign in to comment.