- fix leak in HttpResponse::setData()
authorMichael Wallner <mike@php.net>
Fri, 27 Oct 2006 07:57:59 +0000 (07:57 +0000)
committerMichael Wallner <mike@php.net>
Fri, 27 Oct 2006 07:57:59 +0000 (07:57 +0000)
- allow array parameters to be NULL in several methods

http_message_object.c
http_request_object.c
http_response_object.c

index c984e960fa00a34e2da1a78f282c55784d1e8443..044df4c58616087b61a41646cfd9c97de6127fc1 100644 (file)
@@ -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);
+       }
 }
 /* }}} */
 
index f8347f780877e1792cebe9fec9a7c3a13c1d6de0..8e0b7ce8bb8726c34add518cdb54f16ab29d45d5 100644 (file)
@@ -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;
index 52a1dd1cc1efc4b7f62ee5ed79976103c1c3adc5..0e860bf95da232c3a8d6ecd9c7dee44e21387fd9 100644 (file)
@@ -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) {