From 970dcd240f4ecd3e19a12f940aa85bbc29c3f146 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 15 Feb 2019 17:36:40 +0100 Subject: [PATCH] Don't assume that all includes have been executed --- ext/opcache/ZendAccelerator.c | 4 ++-- ext/opcache/tests/preload_007.phpt | 15 +++++++++++++++ ext/opcache/tests/preload_include.inc | 7 +++++++ ext/opcache/tests/preload_include_dummy.inc | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 ext/opcache/tests/preload_007.phpt create mode 100644 ext/opcache/tests/preload_include.inc create mode 100644 ext/opcache/tests/preload_include_dummy.inc diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 3214477e63b..d03a8b3116d 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3565,7 +3565,7 @@ static void preload_remove_empty_includes(void) if (resolved_path) { zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path); zend_string_release(resolved_path); - if (!incl->empty) { + if (!incl || !incl->empty) { empty = 0; break; } @@ -3604,7 +3604,7 @@ static void preload_remove_empty_includes(void) if (resolved_path) { zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path); - if (incl->empty) { + if (incl && incl->empty) { MAKE_NOP(opline); } else { if (!IS_ABSOLUTE_PATH(Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), Z_STRLEN_P(RT_CONSTANT(opline, opline->op1)))) { diff --git a/ext/opcache/tests/preload_007.phpt b/ext/opcache/tests/preload_007.phpt new file mode 100644 index 00000000000..2054cd8740d --- /dev/null +++ b/ext/opcache/tests/preload_007.phpt @@ -0,0 +1,15 @@ +--TEST-- +Handling of includes that were not executed +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.preload={PWD}/preload_include.inc +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Foobar diff --git a/ext/opcache/tests/preload_include.inc b/ext/opcache/tests/preload_include.inc new file mode 100644 index 00000000000..95369e7b6a2 --- /dev/null +++ b/ext/opcache/tests/preload_include.inc @@ -0,0 +1,7 @@ +