From 4b70d45fc9636a1e41991df67dc087217845bb12 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Sun, 1 Jan 2006 22:11:03 +0000 Subject: [PATCH] remove a host of small problems found by testing 016.phpt --- ext/phar/phar.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 1f7229dc87..77e52297fc 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -590,10 +590,9 @@ PHP_PHAR_API php_stream * php_stream_phar_url_wrapper(php_stream_wrapper *wrappe buffer = (char *) emalloc(idata->internal_file->compressed_filesize); if (idata->internal_file->compressed_filesize != php_stream_read(fp, buffer, idata->internal_file->compressed_filesize)) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (filesize mismatch on file \"%s\")", idata->data->file, internal_file); php_stream_close(fp); - buffer = idata->data->file; efree(idata); - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (filesize mismatch on file \"%s\")", buffer, internal_file); efree(internal_file); return NULL; } @@ -659,32 +658,30 @@ PHP_PHAR_API php_stream * php_stream_phar_url_wrapper(php_stream_wrapper *wrappe php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: decompression failed"); return NULL; } -#define PHAR_ZLIB_ERROR efree(savebuf);\ - buffer = idata->data->file;\ - efree(idata->file);\ - efree(idata);\ - return NULL; efree(savebuf); /* check length */ if (actual_length != idata->internal_file->uncompressed_filesize) { - PHAR_ZLIB_ERROR php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (filesize mismatch on file \"%s\")", buffer, internal_file); efree(internal_file); + efree(idata->file); + efree(idata); return NULL; } /* check crc32/filesize */ if (!idata->internal_file->crc_checked) { status = phar_postprocess_file(idata->file, idata->internal_file->uncompressed_filesize, crc32, 0); if (-1 == status) { - PHAR_ZLIB_ERROR php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (crc32 mismatch on file \"%s\")", buffer, internal_file); + efree(idata->file); + efree(idata); efree(internal_file); return NULL; } if (-2 == status) { - PHAR_ZLIB_ERROR php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (filesize mismatch on file \"%s\")", buffer, internal_file); + efree(idata->file); + efree(idata); efree(internal_file); return NULL; } @@ -695,7 +692,7 @@ PHP_PHAR_API php_stream * php_stream_phar_url_wrapper(php_stream_wrapper *wrappe efree(internal_file); return NULL; #endif - } else { + } else { /* from here is for non-compressed */ idata->file = (char *) emalloc(idata->internal_file->compressed_filesize); if (idata->internal_file->compressed_filesize != php_stream_read(fp, idata->file, idata->internal_file->compressed_filesize)) { -- 2.50.1