Merge branch 'v2.6.x'
authorMichael Wallner <mike@php.net>
Wed, 14 Sep 2016 07:54:24 +0000 (09:54 +0200)
committerMichael Wallner <mike@php.net>
Wed, 14 Sep 2016 07:54:24 +0000 (09:54 +0200)
src/php_http_buffer.c
src/php_http_encoding.c
src/php_http_env_response.c
src/php_http_etag.c
src/php_http_filter.c
src/php_http_message.c

index b214f1d83185db8f345d35e47ca19c02707e7526..d7cfd56c33b207364083a50036cb910398889b98 100644 (file)
@@ -35,9 +35,13 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(
 PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(
                php_http_buffer_t *buf, const char *str, size_t len)
 {
+       int free_buf = !!buf;
+
        if ((buf = php_http_buffer_init(buf))) {
                if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, str, len)) {
-                       pefree(buf, buf->pmem);
+                       if (free_buf) {
+                               pefree(buf, buf->pmem);
+                       }
                        buf = NULL;
                }
        }
index 7fbe7c7a51d49859cbcce173de3bea6083963f91..0aa7dc1638301b58bf66b46d4615e98e81ab6657 100644 (file)
@@ -222,7 +222,7 @@ retry_raw_inflate:
                }
                inflateEnd(&Z);
 
-               if (decoded_len && *decoded) {
+               if (*decoded_len && *decoded) {
                        efree(*decoded);
                }
        }
index 63246988a5b0ba0ac39588eab26de5d6a2660bad..3a5a8e8905539d129335dbe731b29af08b464b7d 100644 (file)
@@ -346,10 +346,6 @@ static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t
                zval_ptr_dtor(zoption);
        }
 
-       if (ret != SUCCESS) {
-               return ret;
-       }
-
        if ((zoption = get_option(options, ZEND_STRL("responseCode"), &zoption_tmp))) {
                zend_long rc = zval_get_long(zoption);
 
index 8c6a5485f0bd2a8247d0b0f7c220aba23d803656..a02548cc028c5d0c81103abc09ce029a60588353 100644 (file)
@@ -79,7 +79,7 @@ char *php_http_etag_finish(php_http_etag_t *e)
 #ifdef PHP_HTTP_HAVE_HASH
                const php_hash_ops *eho = NULL;
 
-               if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
+               if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
                        eho->hash_final(digest, e->ctx);
                        etag = php_http_etag_digest(digest, eho->digest_size);
                }
@@ -109,7 +109,7 @@ size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t dat
 #ifdef PHP_HTTP_HAVE_HASH
                const php_hash_ops *eho = NULL;
 
-               if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
+               if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
                        eho->hash_update(e->ctx, (const unsigned char *) data_ptr, data_len);
                }
 #endif
index f145f02b68a70dbd555483cff72fd4d356552b81..92bfd1554ef946491b6819f5748d5d3b9b83059b 100644 (file)
@@ -302,7 +302,9 @@ static PHP_HTTP_FILTER_FUNCTION(zlib)
                
                nxt = ptr->next;
                php_stream_bucket_unlink(ptr);
-               php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len);
+               if (SUCCESS != php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len)) {
+                       return PSFS_ERR_FATAL;
+               }
                
 #if DBG_FILTER
                fprintf(stderr, "update: deflate (-> %zu) (w: %zu, r: %zu)\n", encoded_len, stream->writepos, stream->readpos);
@@ -322,7 +324,9 @@ static PHP_HTTP_FILTER_FUNCTION(zlib)
                char *encoded = NULL;
                size_t encoded_len = 0;
                
-               php_http_encoding_stream_flush(buffer, &encoded, &encoded_len);
+               if (SUCCESS != php_http_encoding_stream_flush(buffer, &encoded, &encoded_len)) {
+                       return PSFS_ERR_FATAL;
+               }
                
 #if DBG_FILTER
                fprintf(stderr, "flush: deflate (-> %zu)\n", encoded_len);
@@ -340,7 +344,9 @@ static PHP_HTTP_FILTER_FUNCTION(zlib)
                char *encoded = NULL;
                size_t encoded_len = 0;
                
-               php_http_encoding_stream_finish(buffer, &encoded, &encoded_len);
+               if (SUCCESS != php_http_encoding_stream_finish(buffer, &encoded, &encoded_len)) {
+                       return PSFS_ERR_FATAL;
+               }
                
 #if DBG_FILTER
                fprintf(stderr, "finish: deflate (-> %zu)\n", encoded_len);
index 5a5b5ca4f0d222c3e085b8cf763dcbf900fad934..feef2655f565357a9dbb74543da43cdb135755df 100644 (file)
@@ -405,7 +405,7 @@ php_http_message_t *php_http_message_reverse(php_http_message_t *msg)
        if (c > 1) {
                php_http_message_t *tmp = msg, **arr;
 
-               arr = ecalloc(c, sizeof(**arr));
+               arr = ecalloc(c, sizeof(*arr));
                for (i = 0; i < c; ++i) {
                        arr[i] = tmp;
                        tmp = tmp->parent;
@@ -683,7 +683,7 @@ void php_http_message_object_reverse(zval *zmsg, zval *return_value)
                php_http_message_object_t **objects;
                int last;
 
-               objects = ecalloc(i, sizeof(**objects));
+               objects = ecalloc(i, sizeof(*objects));
 
                /* we are the first message */
                objects[0] = obj;