Skip to content

Commit 6f1b8fa

Browse files
committed
Clean up implementation of get_deprecation_suffix_from_attribute()
1 parent 93fc073 commit 6f1b8fa

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

Zend/zend_execute.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,36 +1741,42 @@ ZEND_COLD static zend_result ZEND_FASTCALL get_deprecation_suffix_from_attribute
17411741
return SUCCESS;
17421742
}
17431743

1744+
zend_result result = FAILURE;
1745+
17441746
zend_string *message = zend_empty_string;
17451747
zend_string *since = zend_empty_string;
17461748

17471749
zval obj;
17481750
ZVAL_UNDEF(&obj);
1749-
zval *z = NULL;
1750-
zend_string *property;
1751+
zval *z;
1752+
zend_string *property = zend_empty_string;
1753+
1754+
/* Construct the Deprecated object to correctly handle parameter processing. */
17511755
if (FAILURE == zend_get_attribute_object(&obj, zend_ce_deprecated, deprecated, scope, NULL)) {
1752-
return FAILURE;
1756+
goto out;
17531757
}
17541758

1759+
/* Extract the $message property. */
1760+
zend_string_release(property);
17551761
property = ZSTR_KNOWN(ZEND_STR_MESSAGE);
17561762
if ((z = zend_read_property_ex(zend_ce_deprecated, Z_OBJ_P(&obj), property, false, NULL)) == NULL) {
1757-
goto fail;
1763+
goto out;
17581764
}
1759-
zend_string_release(property);
17601765
if (Z_TYPE_P(z) == IS_STRING) {
17611766
message = zend_string_copy(Z_STR_P(z));
17621767
}
17631768

1769+
/* Extract the $since property. */
1770+
zend_string_release(property);
17641771
property = ZSTR_INIT_LITERAL("since", 0);
17651772
if ((z = zend_read_property_ex(zend_ce_deprecated, Z_OBJ_P(&obj), property, false, NULL)) == NULL) {
1766-
goto fail;
1773+
goto out;
17671774
}
1768-
zend_string_release(property);
1769-
17701775
if (Z_TYPE_P(z) == IS_STRING) {
17711776
since = zend_string_copy(Z_STR_P(z));
17721777
}
17731778

1779+
/* Construct the suffix. */
17741780
*message_suffix = zend_strpprintf_unchecked(
17751781
0,
17761782
"%s%S%s%S",
@@ -1780,20 +1786,16 @@ ZEND_COLD static zend_result ZEND_FASTCALL get_deprecation_suffix_from_attribute
17801786
message
17811787
);
17821788

1783-
zend_string_release(since);
1784-
zend_string_release(message);
1785-
zval_ptr_dtor(&obj);
1789+
result = SUCCESS;
17861790

1787-
return SUCCESS;
1791+
out:
17881792

1789-
fail:
17901793
zend_string_release(since);
17911794
zend_string_release(message);
17921795
zval_ptr_dtor(&obj);
1793-
zval_ptr_dtor(z);
17941796
zend_string_release(property);
17951797

1796-
return FAILURE;
1798+
return result;
17971799
}
17981800

17991801
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)

0 commit comments

Comments
 (0)