]> granicus.if.org Git - php/commitdiff
Fixed bug #19921. (memory leak introduced by me in rev 1.492)
authorIlia Alshanetsky <iliaa@php.net>
Wed, 16 Oct 2002 16:52:08 +0000 (16:52 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 16 Oct 2002 16:52:08 +0000 (16:52 +0000)
main/main.c

index 9415bcaed3f5686c9ff5990c717d1d02c6a40dc9..3b2dc0d10707140248622344930ac46c8d41fc2d 100644 (file)
@@ -1479,6 +1479,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
        zend_file_handle *prepend_file_p, *append_file_p;
        zend_file_handle prepend_file, append_file;
        char *old_cwd;
+       char *old_primary_file_path = NULL;
        int retval = 0;
 
        EG(exit_status) = 0;
@@ -1509,10 +1510,9 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
                        if (VCWD_REALPATH(primary_file->filename, realfile)) {
                                realfile_len =  strlen(realfile);
                                zend_hash_add(&EG(included_files), realfile, realfile_len+1, (void *)&dummy, sizeof(int), NULL);
-                               if (primary_file->opened_path == NULL && strncmp(realfile, primary_file->filename, realfile_len)) {
-                                       primary_file->opened_path = emalloc(realfile_len+1);
-                                       memcpy(primary_file->opened_path, realfile, realfile_len);
-                                       primary_file->opened_path[realfile_len] = '\0';
+                               if (strncmp(realfile, primary_file->filename, realfile_len)) {
+                                       old_primary_file_path = primary_file->filename;
+                                       primary_file->filename = realfile;
                                }       
                        }
                }
@@ -1540,6 +1540,11 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
                php_mbstring_set_zend_encoding(TSRMLS_C);
 #endif /* ZEND_MULTIBYTE && HAVE_MBSTRING */
                retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
+               
+               if (old_primary_file_path) {
+                       primary_file->filename = old_primary_file_path;
+               }
+               
        } zend_end_try();
 
        if (old_cwd[0] != '\0') {