summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-04-27 17:02:40 +0200
committerNikita Popov <nikita.ppv@gmail.com>2018-04-27 17:02:40 +0200
commit1c887eaf0d07297952b77fd1bd65e80b4b16d7aa (patch)
treec273315ac3aae17618c08fdc5ba8f696fc9622ad
parent31914a827e4fddef8b5f2e8614af651ae8c9361a (diff)
parent2c602be7c85bf41c0aa7cd2b250b39bdac03a960 (diff)
downloadphp-git-1c887eaf0d07297952b77fd1bd65e80b4b16d7aa.tar.gz
Merge branch 'PHP-7.2'
-rw-r--r--ext/opcache/Optimizer/block_pass.c5
-rw-r--r--ext/opcache/tests/bug76275.phpt29
-rw-r--r--ext/opcache/zend_file_cache.c4
3 files changed, 37 insertions, 1 deletions
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index e32f3a7671..7a494ae5a1 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -1049,6 +1049,11 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op
}
if (i != j) {
op_array->last_try_catch = j;
+ if (j == 0) {
+ efree(op_array->try_catch_array);
+ op_array->try_catch_array = NULL;
+ }
+
if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
zend_op *opline = new_opcodes;
zend_op *end = opline + len;
diff --git a/ext/opcache/tests/bug76275.phpt b/ext/opcache/tests/bug76275.phpt
new file mode 100644
index 0000000000..82e4272185
--- /dev/null
+++ b/ext/opcache/tests/bug76275.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #76275: Assertion failure in file cache when unserializing empty try_catch_array
+--INI--
+opcache.enabled=1
+opcache.enable_cli=1
+opcache.file_cache=/tmp
+--FILE--
+<?php
+
+if (PHP_VERSION_ID >= 70000) {
+ echo "Done";
+ return;
+}
+
+if (!is_callable('random_bytes')) {
+ try {
+ } catch (com_exception $e) {
+ }
+
+ function random_bytes($length)
+ {
+ throw new Exception(
+ 'There is no suitable CSPRNG installed on your system'
+ );
+ return '';
+ }
+}
+--EXPECT--
+Done
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index e3e9cfb6c1..6f6b05c45c 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -96,8 +96,10 @@ static int zend_file_cache_flock(int fd, int type)
#define IS_SERIALIZED_INTERNED(ptr) \
((size_t)(ptr) & Z_UL(1))
+
+/* Allowing == here to account for a potential empty allocation at the end of the memory */
#define IS_SERIALIZED(ptr) \
- ((char*)(ptr) < (char*)script->size)
+ ((char*)(ptr) <= (char*)script->size)
#define IS_UNSERIALIZED(ptr) \
(((char*)(ptr) >= (char*)script->mem && (char*)(ptr) < (char*)script->mem + script->size) || \
IS_ACCEL_INTERNED(ptr))