fix resource leaks
authorMichael Wallner <mike@php.net>
Tue, 14 Jul 2015 16:59:06 +0000 (18:59 +0200)
committerMichael Wallner <mike@php.net>
Tue, 14 Jul 2015 16:59:06 +0000 (18:59 +0200)
php_http_message.c
php_http_message_body.c

index d61644ce3de734b2c7bda3598f5d91bf643b5e7f..a6b30f5ca9b2c9f57474a544435c702d6496ead0 100644 (file)
@@ -776,10 +776,11 @@ ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *msg
        }
        if (msg_obj->message) {
                php_http_message_body_free(&msg_obj->message->body);
-               msg_obj->message->body = php_http_message_body_init(&body_obj->body, NULL);
+               msg_obj->message->body = body_obj->body;
        } else {
-               msg_obj->message = php_http_message_init(NULL, 0, php_http_message_body_init(&body_obj->body, NULL));
+               msg_obj->message = php_http_message_init(NULL, 0, body_obj->body);
        }
+       php_http_message_body_addref(body_obj->body);
        msg_obj->body = body_obj;
 
        return SUCCESS;
index ab5b7ba87765fa7fb1df2010696c1dcb2132c09c..d629ae53ad5d137eca73be4c5fc7f51ce538e916 100644 (file)
@@ -37,7 +37,7 @@ php_http_message_body_t *php_http_message_body_init(php_http_message_body_t **bo
 
        if (body_ptr && *body_ptr) {
                body = *body_ptr;
-               ++body->refcount;
+               php_http_message_body_addref(body);
                return body;
        }