hashtable==zend_array now
[m6w6/ext-http] / php_http_client_curl.c
index 05db912a1cb05da061e110ce4d8eaa9baa267830..c50779916ff3fc40cf609c03e9ee13d48ffe46b7 100644 (file)
@@ -1111,11 +1111,14 @@ static ZEND_RESULT_CODE php_http_curle_option_set_proxyheader(php_http_option_t
                {
                        if (header_key.key) {
                                zend_string *zs = zval_get_string(header_val);
+
                                php_http_buffer_appendf(&header, "%s: %s", header_key.key->val, zs->val);
+                               zend_string_release(zs);
+
                                php_http_buffer_fix(&header);
                                curl->options.proxyheaders = curl_slist_append(curl->options.proxyheaders, header.data);
                                php_http_buffer_reset(&header);
-                               zend_string_release(zs);
+
                        }
                }
                ZEND_HASH_FOREACH_END();
@@ -1503,9 +1506,11 @@ static zval *php_http_curle_get_option(php_http_option_t *opt, HashTable *option
        zval *option;
 
        if ((option = php_http_option_get(opt, options, NULL))) {
-               Z_TRY_ADDREF_P(option);
-               convert_to_explicit_type_ex(option, opt->type);
-               zend_hash_update(&curl->options.cache, opt->name, option);
+               zval zopt;
+
+               ZVAL_DUP(&zopt, option);
+               convert_to_explicit_type(option, opt->type);
+               zend_hash_update(&curl->options.cache, opt->name, &zopt);
        }
        return option;
 }
@@ -1834,11 +1839,23 @@ static void php_http_client_curl_handler_dtor(php_http_client_curl_handler_t *ha
        php_http_buffer_dtor(&handler->options.cookies);
        zend_hash_destroy(&handler->options.cache);
 
+#if PHP_HTTP_CURL_VERSION(7,21,3)
+       if (handler->options.resolve) {
+               curl_slist_free_all(handler->options.resolve);
+               handler->options.resolve = NULL;
+       }
+#endif
+
        if (handler->options.headers) {
                curl_slist_free_all(handler->options.headers);
                handler->options.headers = NULL;
        }
 
+       if (handler->options.proxyheaders) {
+               curl_slist_free_all(handler->options.proxyheaders);
+               handler->options.proxyheaders = NULL;
+       }
+
        efree(handler);
 }
 
@@ -1920,8 +1937,6 @@ static php_resource_factory_t *create_rf(php_http_url_t *url)
                rf = php_resource_factory_init(NULL, &php_http_curle_resource_factory_ops, NULL, NULL);
        }
 
-       zend_string_release(id);
-
        return rf;
 }