|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-11-23 20:35 UTC] vrana@php.net
Description:
------------
PHP crashes when there is a static property defined in a trait plus there is a normal property of the same name in a class using this trait.
Test script:
---------------
<?php
trait PropertiesTrait {
static $same = true;
}
class Properties {
use PropertiesTrait;
public $same = true;
}
?>
Expected result:
----------------
Exit code: 0
Actual result:
--------------
Exit code: -1073741819
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 08:00:02 2025 UTC |
Thanks. I just missed the statics here. Patch below, svn commit coming as soon as the tests have completed. Thanks for the catch. Index: Zend/zend_compile.c =================================================================== --- Zend/zend_compile.c (revision 319492) +++ Zend/zend_compile.c (working copy) @@ -4271,10 +4286,11 @@ /* this one is inherited, lets look it up in its own class */ zend_hash_quick_find(&coliding_prop->ce->properties_info, prop_name, prop_name_length+1, prop_hash, (void **) &coliding_prop); } - if ((coliding_prop->flags & ZEND_ACC_PPP_MASK) == (property_info->flags & ZEND_ACC_PPP_MASK)) { + if ( (coliding_prop->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC)) + == (property_info->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) { /* flags are identical, now the value needs to be checked */ if (property_info->flags & ZEND_ACC_STATIC) { - not_compatible = (FAILURE == compare_function(&compare_result, + not_compatible = (FAILURE == compare_function(&compare_result, ce->default_static_members_table[coliding_prop->offset], ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC)) || (Z_LVAL(compare_result) != 0);