aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/erl_tar.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-03-09 16:15:13 +0100
committerBjörn Gustavsson <[email protected]>2017-03-10 10:37:49 +0100
commit59524c3fff40ac9792bb92449eb594fed52b423e (patch)
tree77cc09bdd9eee8340c5f188f30073f69dd6f2375 /lib/stdlib/src/erl_tar.erl
parent1f38a7d26ef86676ad6be0d2bce9b65c1f87253b (diff)
downloadotp-59524c3fff40ac9792bb92449eb594fed52b423e.tar.gz
otp-59524c3fff40ac9792bb92449eb594fed52b423e.tar.bz2
otp-59524c3fff40ac9792bb92449eb594fed52b423e.zip
erl_tar: Close files after reading from a tar file
Also let the test suite verify that all files that are opened will be closed before the end of each test case. aa0c4b0df7cdc7 introduced the file descriptor leak.
Diffstat (limited to 'lib/stdlib/src/erl_tar.erl')
-rw-r--r--lib/stdlib/src/erl_tar.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/stdlib/src/erl_tar.erl b/lib/stdlib/src/erl_tar.erl
index 086e77cd28..a54df939bf 100644
--- a/lib/stdlib/src/erl_tar.erl
+++ b/lib/stdlib/src/erl_tar.erl
@@ -1321,7 +1321,11 @@ foldl_read(TarName, Fun, Accu, #read_opts{}=Opts)
when is_function(Fun,4) ->
try open(TarName, [read|Opts#read_opts.open_mode]) of
{ok, #reader{access=read}=Reader} ->
- foldl_read(Reader, Fun, Accu, Opts);
+ try
+ foldl_read(Reader, Fun, Accu, Opts)
+ after
+ _ = close(Reader)
+ end;
{error, _} = Err ->
Err
catch