From: Michael Wallner Date: Fri, 27 Oct 2006 07:57:59 +0000 (+0000) Subject: - fix leak in HttpResponse::setData() X-Git-Tag: RELEASE_1_3_3~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3952cccee20bf827c2c68ab121d2f5670a036660;p=m6w6%2Fext-http - fix leak in HttpResponse::setData() - allow array parameters to be NULL in several methods --- diff --git a/http_message_object.c b/http_message_object.c index c984e96..044df4c 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -846,16 +846,18 @@ PHP_METHOD(HttpMessage, getHeaders) */ PHP_METHOD(HttpMessage, setHeaders) { - zval *new_headers, old_headers; + zval *new_headers = NULL, old_headers; getObject(http_message_object, obj); - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &new_headers)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!", &new_headers)) { return; } zend_hash_clean(&obj->message->hdrs); - INIT_ZARR(old_headers, &obj->message->hdrs); - array_copy(new_headers, &old_headers); + if (new_headers) { + INIT_ZARR(old_headers, &obj->message->hdrs); + array_copy(new_headers, &old_headers); + } } /* }}} */ diff --git a/http_request_object.c b/http_request_object.c index f8347f7..8e0b7ce 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -1749,7 +1749,7 @@ PHP_METHOD(HttpRequest, getResponseCookies) long flags = 0; zval *allowed_extras_array = NULL; - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|la", &flags, &allowed_extras_array)) { + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|la!", &flags, &allowed_extras_array)) { int i = 0; ulong idx = 0; char *key = NULL, **allowed_extras = NULL; diff --git a/http_response_object.c b/http_response_object.c index 52a1dd1..0e860bf 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -817,7 +817,7 @@ PHP_METHOD(HttpResponse, setData) char *etag; zval *the_data; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &the_data)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &the_data)) { RETURN_FALSE; } if (Z_TYPE_P(the_data) != IS_STRING) {