From: Greg Beaver Date: Tue, 11 Dec 2007 19:28:35 +0000 (+0000) Subject: use thread-safe global var to store zend_compile_file, and restore the current zend_c... X-Git-Tag: RELEASE_2_0_0a1~1204 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a614e30db615790438849281ccaae25d30fa6df;p=php use thread-safe global var to store zend_compile_file, and restore the current zend_compile_file, not the one we found in MINIT --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 70ac030d8f..15eac56bc8 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -3741,15 +3741,15 @@ static void php_phar_init_globals_module(zend_phar_globals *phar_globals) } /* }}} */ -static zend_op_array *(*orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); - static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */ { zend_op_array *res; char *fname = NULL; int fname_len; + zend_op_array *(*save)(zend_file_handle *file_handle, int type TSRMLS_DC); - zend_compile_file = orig_compile_file; + save = zend_compile_file; /* restore current handler or we cause trouble */ + zend_compile_file = PHAR_G(orig_compile_file); if (zend_hash_num_elements(&(PHAR_GLOBALS->phar_fname_map))) { char *arch, *entry; int arch_len, entry_len; @@ -3780,8 +3780,8 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type } } skip_phar: - res = orig_compile_file(file_handle, type TSRMLS_CC); - zend_compile_file = phar_compile_file; + res = zend_compile_file(file_handle, type TSRMLS_CC); + zend_compile_file = save; return res; } /* }}} */ @@ -3794,7 +3794,7 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */ PHAR_G(has_gnupg) = zend_hash_exists(&module_registry, "gnupg", sizeof("gnupg")); PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2")); PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib")); - orig_compile_file = zend_compile_file; + PHAR_G(orig_compile_file) = zend_compile_file; zend_compile_file = phar_compile_file; phar_object_init(TSRMLS_C); @@ -3805,7 +3805,9 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */ PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */ { return php_unregister_url_stream_wrapper("phar" TSRMLS_CC); - zend_compile_file = orig_compile_file; + if (zend_compile_file == phar_compile_file) { + zend_compile_file = PHAR_G(orig_compile_file); + } } /* }}} */ diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 0c4e85c436..ada891eb6b 100755 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -117,6 +117,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phar) int has_bz2:1; int has_gnupg:1; int has_zlib:1; + zend_op_array *(*orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); ZEND_END_MODULE_GLOBALS(phar) ZEND_EXTERN_MODULE_GLOBALS(phar)