diff options
author | Erik Troan <ewt@redhat.com> | 2001-12-10 21:39:32 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2001-12-10 21:39:32 +0000 |
commit | d72ddbf67c78496feb5823e58af085fe48fa2a8b (patch) | |
tree | 1f4689a97472b29d54f162bf0773bbdb32c48c6f /isys/gzlib | |
parent | 6afed5ca543aa740ee9c92967ac15263fe924188 (diff) | |
download | anaconda-d72ddbf67c78496feb5823e58af085fe48fa2a8b.tar.gz anaconda-d72ddbf67c78496feb5823e58af085fe48fa2a8b.tar.xz anaconda-d72ddbf67c78496feb5823e58af085fe48fa2a8b.zip |
don't leave open file descriptors -- very bad idea
Diffstat (limited to 'isys/gzlib')
-rw-r--r-- | isys/gzlib/binding.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/isys/gzlib/binding.c b/isys/gzlib/binding.c index 773033902..55e512d26 100644 --- a/isys/gzlib/binding.c +++ b/isys/gzlib/binding.c @@ -49,11 +49,15 @@ gzFile gunzip_dopen(int fd) { gzFile gunzip_open(const char * file) { int fd; + gzFile rc; fd = open(file, O_RDONLY); if (fd < 0) return NULL; - return gunzip_dopen(fd); + rc = gunzip_dopen(fd); + close(fd); + + return rc; } gzFile gzip_dopen(int fd) { @@ -93,11 +97,15 @@ gzFile gzip_dopen(int fd) { gzFile gzip_open(const char * file, int flags, int perms) { int fd; + gzFile rc; fd = open(file, flags, perms); if (fd < 0) return NULL; - return gzip_dopen(fd); + rc = gzip_dopen(fd); + close(fd); + + return rc; } int gunzip_read(gzFile str, void * buf, int bytes) { |