mirror of
https://github.com/php/php-src.git
synced 2024-09-23 10:57:26 +00:00
Fixed bug #41633 (Crash instantiating classes with self-referencing constants)
This commit is contained in:
parent
b898c98005
commit
0a7462e056
12
Zend/tests/bug41633_3.phpt
Executable file
12
Zend/tests/bug41633_3.phpt
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
--TEST--
|
||||||
|
Bug #41633.3 (Crash instantiating classes with self-referencing constants)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
class Foo {
|
||||||
|
const A = Foo::B;
|
||||||
|
const B = Foo::A;
|
||||||
|
}
|
||||||
|
echo Foo::A;
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Fatal error: Cannot declare self-referencing constant 'Foo::B' in %sbug41633_3.php on line %d
|
@ -469,6 +469,10 @@ ZEND_API int zend_is_true(zval *op)
|
|||||||
|
|
||||||
#include "../TSRM/tsrm_strtok_r.h"
|
#include "../TSRM/tsrm_strtok_r.h"
|
||||||
|
|
||||||
|
#define IS_VISITED_CONSTANT IS_CONSTANT_INDEX
|
||||||
|
#define IS_CONSTANT_VISITED(p) (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
|
||||||
|
#define MARK_CONSTANT_VISITED(p) Z_TYPE_P(p) |= IS_VISITED_CONSTANT
|
||||||
|
|
||||||
ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC)
|
ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *p = *pp;
|
zval *p = *pp;
|
||||||
@ -476,13 +480,17 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
|
|||||||
zval const_value;
|
zval const_value;
|
||||||
zstr colon;
|
zstr colon;
|
||||||
|
|
||||||
if (Z_TYPE_P(p) == IS_CONSTANT) {
|
if (IS_CONSTANT_VISITED(p)) {
|
||||||
|
zend_error(E_ERROR, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p));
|
||||||
|
} else if (Z_TYPE_P(p) == IS_CONSTANT) {
|
||||||
int refcount;
|
int refcount;
|
||||||
zend_uchar is_ref;
|
zend_uchar is_ref;
|
||||||
|
|
||||||
SEPARATE_ZVAL_IF_NOT_REF(pp);
|
SEPARATE_ZVAL_IF_NOT_REF(pp);
|
||||||
p = *pp;
|
p = *pp;
|
||||||
|
|
||||||
|
MARK_CONSTANT_VISITED(p);
|
||||||
|
|
||||||
refcount = p->refcount;
|
refcount = p->refcount;
|
||||||
is_ref = p->is_ref;
|
is_ref = p->is_ref;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user