From: Michael Wallner Date: Fri, 1 Aug 2014 07:22:56 +0000 (+0200) Subject: ensure string and custom options are reset properly X-Git-Tag: RELEASE_2_1_0_RC1~3 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=007ef072341b5d6fed93d7f0a4c64369a2536fa5 ensure string and custom options are reset properly --- diff --git a/php_http_client_curl.c b/php_http_client_curl.c index 1e6d667..15d2619 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -815,19 +815,20 @@ static STATUS php_http_curle_option_set_cookiestore(php_http_option_t *opt, zval { php_http_client_curl_handler_t *curl = userdata; CURL *ch = curl->handle; + php_http_curle_storage_t *storage = php_http_curle_get_storage(curl->handle); - if (val) { - php_http_curle_storage_t *storage = php_http_curle_get_storage(curl->handle); - - if (storage->cookiestore) { - pefree(storage->cookiestore, 1); - } + if (storage->cookiestore) { + pefree(storage->cookiestore, 1); + } + if (val && Z_STRLEN_P(val)) { storage->cookiestore = pestrndup(Z_STRVAL_P(val), Z_STRLEN_P(val), 1); - if ( CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore) - || CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore) - ) { - return FAILURE; - } + } else { + storage->cookiestore = NULL; + } + if ( CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore) + || CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore) + ) { + return FAILURE; } return SUCCESS; } @@ -870,6 +871,11 @@ static STATUS php_http_curle_option_set_cookies(php_http_option_t *opt, zval *va } } } + } else { + php_http_buffer_reset(&curl->options.cookies); + if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, NULL)) { + return FAILURE; + } } return SUCCESS; }