summaryrefslogtreecommitdiff
path: root/ext/zlib/zlib_filter.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zlib/zlib_filter.c')
-rw-r--r--ext/zlib/zlib_filter.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c
index 4990cf0..0f6c056 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -80,8 +80,11 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
while (buckets_in->head) {
size_t bin = 0, desired;
+ bucket = buckets_in->head;
+
bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC);
- while (bin < bucket->buflen) {
+
+ while (bin < (unsigned int) bucket->buflen) {
if (data->finished) {
consumed += bucket->buflen;
@@ -107,7 +110,6 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
desired -= data->strm.avail_in; /* desired becomes what we consumed this round through */
data->strm.next_in = data->inbuf;
data->strm.avail_in = 0;
- consumed += desired;
bin += desired;
if (data->strm.avail_out < data->outbuf_len) {
@@ -123,7 +125,9 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
php_stream_bucket_delref(bucket TSRMLS_CC);
return PSFS_PASS_ON;
}
+
}
+ consumed += bucket->buflen;
php_stream_bucket_delref(bucket TSRMLS_CC);
}
@@ -202,9 +206,11 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
while (buckets_in->head) {
size_t bin = 0, desired;
- bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC);
+ bucket = buckets_in->head;
+
+ bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC);
- while (bin < bucket->buflen) {
+ while (bin < (unsigned int) bucket->buflen) {
desired = bucket->buflen - bin;
if (desired > data->inbuf_len) {
desired = data->inbuf_len;
@@ -221,7 +227,6 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
desired -= data->strm.avail_in; /* desired becomes what we consumed this round through */
data->strm.next_in = data->inbuf;
data->strm.avail_in = 0;
- consumed += desired;
bin += desired;
if (data->strm.avail_out < data->outbuf_len) {
@@ -235,6 +240,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
exit_status = PSFS_PASS_ON;
}
}
+ consumed += bucket->buflen;
php_stream_bucket_delref(bucket TSRMLS_CC);
}
@@ -258,6 +264,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
if (bytes_consumed) {
*bytes_consumed = consumed;
}
+
return exit_status;
}
@@ -291,7 +298,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
/* Create this filter */
data = pecalloc(1, sizeof(php_zlib_filter_data), persistent);
if (!data) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", sizeof(php_zlib_filter_data));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", sizeof(php_zlib_filter_data));
return NULL;
}
@@ -303,14 +310,14 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048;
data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent);
if (!data->inbuf) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", data->inbuf_len);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len);
pefree(data, persistent);
return NULL;
}
data->strm.avail_in = 0;
data->strm.next_out = data->outbuf = (Bytef *) pemalloc(data->outbuf_len, persistent);
if (!data->outbuf) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", data->outbuf_len);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->outbuf_len);
pefree(data->inbuf, persistent);
pefree(data, persistent);
return NULL;
@@ -409,7 +416,7 @@ factory_setlevel:
}
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filter parameter, ignored.");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filter parameter, ignored");
}
}
status = deflateInit2(&(data->strm), level, Z_DEFLATED, windowBits, memLevel, 0);