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

@@@ -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
@@@ -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
@@@ -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