fix messagebody gc/refcount
authorMichael Wallner <mike@php.net>
Wed, 27 Jul 2016 12:54:56 +0000 (14:54 +0200)
committerMichael Wallner <mike@php.net>
Wed, 27 Jul 2016 12:54:56 +0000 (14:54 +0200)
src/php_http_message_body.c

index 3ab57f27e4c57f4e8f5a5bfe1650409b038f5030..18859a3b409cb8fe1a4d30479892f62afa37fc55 100644 (file)
@@ -46,10 +46,11 @@ php_http_message_body_t *php_http_message_body_init(php_http_message_body_t **bo
 
        if (stream) {
                body->res = stream->res;
+               ++GC_REFCOUNT(body->res);
        } else {
                body->res = php_stream_temp_create(TEMP_STREAM_DEFAULT, 0xffff)->res;
        }
-       ++GC_REFCOUNT(body->res);
+       php_stream_auto_cleanup(php_http_message_body_stream(body));
 
        if (body_ptr) {
                *body_ptr = body;
@@ -91,6 +92,7 @@ void php_http_message_body_free(php_http_message_body_t **body_ptr)
                php_http_message_body_t *body = *body_ptr;
 
                if (!--body->refcount) {
+                       zend_list_delete(body->res);
                        PTR_FREE(body->boundary);
                        efree(body);
                }