From: Sterling Hughes Date: Mon, 4 Dec 2000 15:05:23 +0000 (+0000) Subject: close the filehandle if it is a tempfile. X-Git-Tag: php-4.0.5RC1~1028 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d322a13a238f8c9c0538d7572134b42dde5ef64;p=php close the filehandle if it is a tempfile. --- diff --git a/ext/curl/curl.c b/ext/curl/curl.c index d2a30af418..b908f2b23b 100644 --- a/ext/curl/curl.c +++ b/ext/curl/curl.c @@ -300,7 +300,7 @@ PHP_FUNCTION(curl_init) } memset(curl_handle, 0, sizeof(php_curl)); - zend_llist_init(&curl_handle->to_free,sizeof(char *),curl_free_string,0); + zend_llist_init(&curl_handle->to_free, sizeof(char *), curl_free_string, 0); curl_handle->cp = curl_easy_init(); if (!curl_handle->cp) { @@ -576,7 +576,8 @@ PHP_FUNCTION(curl_exec) CURLcode ret; FILE *fp; char buf[4096]; - int b; + int b, + is_temp_file; unsigned long pos = 0; if (ZEND_NUM_ARGS() != 1 || @@ -595,6 +596,8 @@ PHP_FUNCTION(curl_exec) } curl_easy_setopt(curl_handle->cp, CURLOPT_FILE, fp); + + is_temp_file = 1; } else if (curl_handle->return_transfer && curl_handle->output_file) { @@ -614,6 +617,9 @@ PHP_FUNCTION(curl_exec) } else { RETURN_TRUE; } + + if (fp && is_temp_file) + fclose(fp); } @@ -625,6 +631,9 @@ PHP_FUNCTION(curl_exec) php_write(buf, b); } + if (is_temp_file) + fclose(fp); + } else { char *ret_data; @@ -642,6 +651,9 @@ PHP_FUNCTION(curl_exec) } ret_data[stat_sb.st_size - 1] = '\0'; + if (is_temp_file) + fclose(fp); + RETURN_STRINGL(ret_data, stat_sb.st_size, 0); }