diff options
author | Wez Furlong <wez@php.net> | 2002-03-16 14:39:51 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2002-03-16 14:39:51 +0000 |
commit | bed04279c3f8ef7dbb3aa0c0543d50f72248cb2c (patch) | |
tree | 7db0b1720fc4d859b4cc95e9ab6af672c7b78cb1 /ext/zlib/zlib_fopen_wrapper.c | |
parent | 6abd7c6f93c4ec981219745ac8882d99741fe50b (diff) | |
download | php-git-bed04279c3f8ef7dbb3aa0c0543d50f72248cb2c.tar.gz |
Hopefully fix resource usage so that we have no leaks and don't segfault.
Diffstat (limited to 'ext/zlib/zlib_fopen_wrapper.c')
-rw-r--r-- | ext/zlib/zlib_fopen_wrapper.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index 061326816c..31589f824b 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -32,7 +32,7 @@ static size_t php_gziop_read(php_stream *stream, char *buf, size_t count) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract; - if (buf == NULL && count == 0) { + if (buf == NULL && count == 0) { if (gzeof(self->gz_file)) return EOF; return 0; @@ -60,13 +60,14 @@ static int php_gziop_seek(php_stream *stream, off_t offset, int whence) return gzseek(self->gz_file, offset, whence); } -static int php_gziop_close(php_stream *stream) +static int php_gziop_close(php_stream *stream, int close_handle) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract; int ret; - ret = gzclose(self->gz_file); - php_stream_close(self->stream); + if (close_handle) + ret = gzclose(self->gz_file); + php_stream_free(self->stream, close_handle); efree(self); return ret; @@ -92,9 +93,9 @@ php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened self->stream = php_stream_open_wrapper(path, mode, options, opened_path TSRMLS_CC); - if (self->stream) { + if (self->stream) { int fd; - if (SUCCESS == php_stream_cast(self->stream, PHP_STREAM_AS_FD, (void**)&fd, REPORT_ERRORS)) { + if (SUCCESS == php_stream_cast(self->stream, PHP_STREAM_AS_FD, (void**)&fd, REPORT_ERRORS)) { self->gz_file = gzdopen(fd, mode); if (self->gz_file) { stream = php_stream_alloc(&php_stream_gzio_ops, self, 0, mode); |