]> granicus.if.org Git - php/commitdiff
close the filehandle if it is a tempfile.
authorSterling Hughes <sterling@php.net>
Mon, 4 Dec 2000 15:05:23 +0000 (15:05 +0000)
committerSterling Hughes <sterling@php.net>
Mon, 4 Dec 2000 15:05:23 +0000 (15:05 +0000)
ext/curl/curl.c

index d2a30af4186a9babff8c3357b6d849ba01ce399c..b908f2b23bf996dd58c67ccf6981f7d0dbf78283 100644 (file)
@@ -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);
        
        }