]> granicus.if.org Git - php/commitdiff
Avoid fd leak which appears when using ZEND_HANDLE_FILENAME
authorSascha Schumann <sas@php.net>
Fri, 26 Nov 1999 19:01:26 +0000 (19:01 +0000)
committerSascha Schumann <sas@php.net>
Fri, 26 Nov 1999 19:01:26 +0000 (19:01 +0000)
sapi/aolserver/aolserver.c

index e6b61e802cf2e5515987d1a98fb40fd17bc8882a..7a3ba47430faeeac6f353903d73f07e6f3e6bfdf 100644 (file)
@@ -383,20 +383,28 @@ static int
 php_ns_module_main(NSLS_D SLS_DC)
 {
        zend_file_handle file_handle;
+       int fd;
        CLS_FETCH();
        ELS_FETCH();
        PLS_FETCH();
 
-       file_handle.type = ZEND_HANDLE_FILENAME;
+       file_handle.type = ZEND_HANDLE_FD;
        file_handle.filename = SG(request_info).path_translated;
+       file_handle.handle.fd = fd = open(SG(request_info).path_translated, O_RDONLY);
+       if (fd == -1) {
+               return NS_ERROR;
+       }
        
-       if(php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
+       if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
+               close(fd);
                return NS_ERROR;
        }
        php_ns_hash_environment(NSLS_C CLS_CC ELS_CC PLS_CC SLS_CC);
        php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
        php_request_shutdown(NULL);
 
+       close(fd);
+
        return NS_OK;
 }