From: Olev Kartau Date: Thu, 10 Jul 2014 14:15:32 +0000 (+0300) Subject: fill_packs_from_git: fix leaking of temporary files X-Git-Tag: 0.14~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fbf969c92ad6fac2e75b3a80ef6f30b4a565b44;p=tools%2Fdepanneur.git 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 --- 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