From 5fbf969c92ad6fac2e75b3a80ef6f30b4a565b44 Mon Sep 17 00:00:00 2001 From: Olev Kartau Date: Thu, 10 Jul 2014 17:15:32 +0300 Subject: [PATCH] fill_packs_from_git: fix leaking of temporary files In this function, all opened temporary files were left undeleted and became garbage in /tmp. CLEANUP is not valid flag for tempfile(). For tempfile, the flag would be UNLINK, but it can't be used when OPEN is set to zero (which is the case). Perl will not automatically delete such files, so we have to close and delete them. Change-Id: Id05ffa5c41f9d7522faa370fb8816ebb64740be6 --- depanneur | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/depanneur b/depanneur index b90d459..0f8ab62 100755 --- a/depanneur +++ b/depanneur @@ -553,8 +553,7 @@ sub fill_packs_from_git { debug("working on $base"); if ($includeall == 0) { - # create temp file and desctroy it autoly - my (undef, $tmp_file) = tempfile(CLEANUP=>1, OPEN => 0); + my (undef, $tmp_file) = tempfile(OPEN => 0); if (my_system("cd $base; git show $spec_commit:$packaging_dir >$tmp_file 2>/dev/null") == 0) { open my $file, '<', $tmp_file or die $!; # the content like: @@ -575,7 +574,7 @@ sub fill_packs_from_git { project_base_path => $base}); } } else { #packaging_dir is a symbol link - my (undef, $tmp_symlink_file) = tempfile(CLEANUP=>1, OPEN => 0); + my (undef, $tmp_symlink_file) = tempfile(OPEN => 0); # git show the real packaging dir if (my_system("cd $base; git show $spec_commit:$first_line >$tmp_symlink_file 2>/dev/null") == 0) { open my $symlink_file, '<', $tmp_symlink_file or die $!; @@ -586,8 +585,12 @@ sub fill_packs_from_git { push(@pre_packs, {filename => "$base/$first_line/$_", project_base_path => $base}); } + close($symlink_file); + unlink $tmp_symlink_file; } } + close($file); + unlink $tmp_file; } } else { # specify --include-all use current packaging dir not from git -- 2.34.1