diff options
author | Kevin Ryde <user42@zip.com.au> | 2004-07-31 01:19:26 +0000 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2004-07-31 01:19:26 +0000 |
commit | 01046395accac9b6de5930bc827d3b08a54a7842 (patch) | |
tree | c8b8e72cbd6f1b2faaa86fd2005f94992022b04f /libguile/filesys.c | |
parent | 3572cd6b8f6c6c9cc6549ab67a179563d89e2ae0 (diff) | |
download | guile-01046395accac9b6de5930bc827d3b08a54a7842.tar.gz |
(scm_copy_file): Avoid fd leak when destination file
cannot be opened.
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index e27bdca99..fa8cd18e1 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1424,7 +1424,10 @@ SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0, newfd = open (SCM_STRING_CHARS (newfile), O_WRONLY | O_CREAT | O_TRUNC, oldstat.st_mode & 07777); if (newfd == -1) - SCM_SYSERROR; + { + close (oldfd); + SCM_SYSERROR; + } while ((n = read (oldfd, buf, sizeof buf)) > 0) if (write (newfd, buf, n) != n) |