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)
1  2 
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,64e559a5907f0c8a051d350d3511f8863fa9a683..d7cfd56c33b207364083a50036cb910398889b98
@@@ -32,12 -30,15 +32,16 @@@ PHP_HTTP_BUFFER_API php_http_buffer_t *
        return buf;
  }
  
 -PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_buffer_t *buf, const char *string, size_t length)
 +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, string, length)) {
 +              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;
                }
        }
Simple merge
index 63246988a5b0ba0ac39588eab26de5d6a2660bad,b4927a16b9553e86191deaa6d53937a0ff75a851..3a5a8e8905539d129335dbe731b29af08b464b7d
@@@ -339,24 -362,21 +339,20 @@@ static ZEND_RESULT_CODE php_http_env_re
                return ret;
        }
  
 -      if ((zoption = get_option(options, ZEND_STRL("headers") TSRMLS_CC))) {
 +      if ((zoption = get_option(options, ZEND_STRL("headers"), &zoption_tmp))) {
                if (Z_TYPE_P(zoption) == IS_ARRAY) {
 -                      php_http_header_to_callback(Z_ARRVAL_P(zoption), 0, (php_http_pass_format_callback_t) r->ops->set_header, r TSRMLS_CC);
 +                      php_http_header_to_callback(Z_ARRVAL_P(zoption), 0, (php_http_pass_format_callback_t) r->ops->set_header, r);
                }
 -              zval_ptr_dtor(&zoption);
 +              zval_ptr_dtor(zoption);
        }
  
-       if (ret != SUCCESS) {
-               return ret;
-       }
 -      if ((zoption = get_option(options, ZEND_STRL("responseCode") TSRMLS_CC))) {
 -              zval *zoption_copy = php_http_ztyp(IS_LONG, zoption);
 +      if ((zoption = get_option(options, ZEND_STRL("responseCode"), &zoption_tmp))) {
 +              zend_long rc = zval_get_long(zoption);
  
 -              zval_ptr_dtor(&zoption);
 -              if (Z_LVAL_P(zoption_copy) > 0) {
 -                      ret = r->ops->set_status(r, Z_LVAL_P(zoption_copy));
 +              zval_ptr_dtor(zoption);
 +              if (rc > 0) {
 +                      ret = r->ops->set_status(r, rc);
                }
 -              zval_ptr_dtor(&zoption_copy);
        }
  
        if (ret != SUCCESS) {
Simple merge
index f145f02b68a70dbd555483cff72fd4d356552b81,9b391048a22408cc95aa50df088b7f4813f59953..92bfd1554ef946491b6819f5748d5d3b9b83059b
@@@ -301,8 -301,10 +301,10 @@@ static PHP_HTTP_FILTER_FUNCTION(zlib
  #endif
                
                nxt = ptr->next;
 -              php_stream_bucket_unlink(ptr TSRMLS_CC);
 +              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);
Simple merge