From: Andrei Zmievski Date: Thu, 14 Feb 2002 04:01:53 +0000 (+0000) Subject: Fix the bug where the declared properties without init values were not X-Git-Tag: php-4.2.0RC1~343 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68a82f14a2d8469baca28d6b8347eff8dfdcca4c;p=php Fix the bug where the declared properties without init values were not entered into the table. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 865cdfc1dc..143ca3589e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1966,23 +1966,27 @@ void zend_do_end_class_declaration(znode *class_token TSRMLS_DC) void zend_do_declare_property(znode *var_name, znode *value, int declaration_type TSRMLS_DC) { - if (value) { - zval *property; + zval *property; - ALLOC_ZVAL(property); + ALLOC_ZVAL(property); + if (value) { *property = value->u.constant; - switch (declaration_type) { - case T_VAR: - zend_hash_update(&CG(active_class_entry)->default_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); - break; - case T_STATIC: - zend_hash_update(CG(active_class_entry)->static_members, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); - break; - case T_CONST: - zend_hash_update(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); - break; - } + } else { + INIT_PZVAL(property); + property->type = IS_NULL; + } + + switch (declaration_type) { + case T_VAR: + zend_hash_update(&CG(active_class_entry)->default_properties, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); + break; + case T_STATIC: + zend_hash_update(CG(active_class_entry)->static_members, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); + break; + case T_CONST: + zend_hash_update(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL); + break; } FREE_PNODE(var_name); }