com php-src: Fixed bug #72014 (Including a file with anonymous classes multiple times leads to fatal error): NEWS ext/opcache/tests/bug72014.phpt
ext/opcache/zend_accelerator_util_funcs.c
| From: | Xinchen Hui | Date: | Thu, 14 Apr 2016 12:21:19 +0000 |
| Subject: | com php-src: Fixed bug #72014 (Including a file with anonymous classes multiple times leads to fatal error): NEWS ext/opcache/tests/bug72014.phpt ext/opcache/zend_accelerator_util_funcs.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91722@lists.php.net to get a copy of this message | ||
Commit: 8a17b1a2415cc3a44b74bb9bab18d6dded1ee9b0
Author: Xinchen Hui <laruence@gmail.com> Thu, 14 Apr 2016 20:21:19 +0800
Parents: ec358dac030b21c963c09892bf168cd6ad145425
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8a17b1a2415cc3a44b74bb9bab18d6dded1ee9b0
Log:
Fixed bug #72014 (Including a file with anonymous classes multiple times leads to fatal error)
Bugs:
https://bugs.php.net/72014
Changed paths:
M NEWS
A ext/opcache/tests/bug72014.phpt
M ext/opcache/zend_accelerator_util_funcs.c
Diff:
diff --git a/NEWS b/NEWS
index 5d13e3c..a9f3293 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #71600 (oci_fetch_all segfaults when selecting more than
eight columns)
+- Opcache:
+ . Fixed bug #72014 (Including a file with anonymous classes multiple times
+ leads to fatal error). (Laruence)
+
- SQLite3:
. Fixed bug #68849 (bindValue is not using the right data type).
(Anatol)
diff --git a/ext/opcache/tests/bug72014.phpt b/ext/opcache/tests/bug72014.phpt
new file mode 100644
index 0000000..d2ad96c
--- /dev/null
+++ b/ext/opcache/tests/bug72014.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #72014 (Including a file with anonymous classes multiple times leads to fatal error)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+file_put_contents(__DIR__ . "/bug72014.annon.php", <<<PHP
+<?php
+\$a = new class() { public \$testvar = "Foo\n"; };
+echo \$a->testvar;
+PHP
+);
+
+include(__DIR__ . "/bug72014.annon.php");
+include(__DIR__ . "/bug72014.annon.php");
+include(__DIR__ . "/bug72014.annon.php");
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . "/bug72014.annon.php")
+?>
+--EXPECT--
+Foo
+Foo
+Foo
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index febda21..2913e40 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -610,7 +610,6 @@ failure:
static void zend_accel_class_hash_copy(HashTable *target, HashTable *source,
unique_copy_ctor_func_t pCopyConstructor)
{
- zend_class_entry *ce1;
Bucket *p, *end;
zval *t;
@@ -626,7 +625,17 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source,
uni
/* Mangled key - ignore and wait for runtime */
continue;
} else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) {
- goto failure;
+ zend_class_entry *ce1 = Z_PTR(p->val);
+ if (!(ce1->ce_flags & ZEND_ACC_ANON_CLASS)) {
+ CG(in_compilation) = 1;
+ zend_set_compiled_filename(ce1->info.user.filename);
+ CG(zend_lineno) = ce1->info.user.line_start;
+ zend_error(E_ERROR,
+ "Cannot declare %s %s, because the name is already in use",
+ zend_get_object_type(ce1), ZSTR_VAL(ce1->name));
+ return;
+ }
+ continue;
}
} else {
t = _zend_hash_append_ptr(target, p->key, Z_PTR(p->val));
@@ -637,13 +646,6 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source,
uni
}
target->nInternalPointer = target->nNumOfElements ? 0 : HT_INVALID_IDX;
return;
-
-failure:
- ce1 = Z_PTR(p->val);
- CG(in_compilation) = 1;
- zend_set_compiled_filename(ce1->info.user.filename);
- CG(zend_lineno) = ce1->info.user.line_start;
- zend_error(E_ERROR, "Cannot declare %s %s, because the name is already in use",
zend_get_object_type(ce1), ZSTR_VAL(ce1->name));
}
#ifdef __SSE2__