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 d61644c..a6b30f5 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 ab5b7ba..d629ae5 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;
        }