]> granicus.if.org Git - php/commitdiff
Revert "Drop free_filename field from zend_file_handle"
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 24 Jul 2019 08:42:19 +0000 (10:42 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 24 Jul 2019 08:43:37 +0000 (10:43 +0200)
This reverts commit e0eca262852dba1a78afcde64a49126c81fead1a.

free_filename is used by the wincache extension, restore this
field for PHP 7.4.

Zend/zend_language_scanner.l
Zend/zend_stream.c
Zend/zend_stream.h
ext/phar/phar.c
sapi/litespeed/lsapi_main.c
sapi/phpdbg/phpdbg_list.c

index fadd2f2a503736b30135acd3596ab37ffe8b1302..1537fa36f8ed74aa74df7599141075bef3e58657 100644 (file)
@@ -292,6 +292,9 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
        zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
        /* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */
        file_handle->opened_path = NULL;
+       if (file_handle->free_filename) {
+               file_handle->filename = NULL;
+       }
 }
 
 ZEND_API void zend_lex_tstring(zval *zv)
index a3490ffc935585faefe1e06ee2d9bdff2a7904ae..4dffc31040831384b7ed8acb2959aa02d053a330 100644 (file)
@@ -223,6 +223,10 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh) /* {{{ */
                efree(fh->buf);
                fh->buf = NULL;
        }
+       if (fh->free_filename && fh->filename) {
+               efree((char*)fh->filename);
+               fh->filename = NULL;
+       }
 }
 /* }}} */
 
index 66a7e5198ceb69f02b3d1f06f4d2ac987eb2d3ba..51651add3827860739f98801caafd5d98c16caa6 100644 (file)
@@ -56,6 +56,9 @@ typedef struct _zend_file_handle {
        const char        *filename;
        zend_string       *opened_path;
        zend_stream_type  type;
+       /* free_filename is used by wincache */
+       /* TODO: Clean up filename vs opened_path mess */
+       zend_bool         free_filename;
        char              *buf;
        size_t            len;
 } zend_file_handle;
index 0deec63368565230962c22b3bcf524e92d8c3f7e..93a03873667b8c6df99e0d00e879b1a46821d6b7 100644 (file)
@@ -3261,6 +3261,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type)
                                                efree(f.opened_path);
                                        }
                                        f.opened_path = file_handle->opened_path;
+                                       f.free_filename = file_handle->free_filename;
 
                                        switch (file_handle->type) {
                                                case ZEND_HANDLE_STREAM:
index a851212c8575ebe64d03dd6f39b3b65faa744d49..f7d4b1a84c019cb6bf1f314031f0b9b24c7cb644 100644 (file)
@@ -1338,6 +1338,7 @@ static int cli_main( int argc, char * argv[] )
                             highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini);
                         } else if (source_highlight == 2) {
                             file_handle.filename = *p;
+                            file_handle.free_filename = 0;
                             file_handle.opened_path = NULL;
                             ret = php_lint_script(&file_handle);
                             if (ret==SUCCESS) {
@@ -1348,6 +1349,7 @@ static int cli_main( int argc, char * argv[] )
 
                         } else {
                             file_handle.filename = *p;
+                            file_handle.free_filename = 0;
                             file_handle.opened_path = NULL;
 
                             php_execute_script(&file_handle);
index fe612be3258e7d3118d6b56d75239d1825f62369..03b4c3526e30e604c91e3f5ffa7ef92b5d293193 100644 (file)
@@ -294,6 +294,10 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
                        zend_string_release(file->opened_path);
                        file->opened_path = zend_string_init(filename, strlen(filename), 0);
                } else {
+                       if (file->free_filename) {
+                               efree((char *) file->filename);
+                       }
+                       file->free_filename = 0;
                        file->filename = filename;
                }
        }