Skip to content

Commit 29d6e29

Browse files
authored
phar: Remove confusing dtor calls (php#20148)
If object initialization fails the zval will be NULL, that's an implementation detail. However, it's very confusing for a reader to destroy a seemingly uninitialized zval.
1 parent 930fe03 commit 29d6e29

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

ext/phar/phar_object.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,6 @@ PHP_METHOD(Phar, buildFromDirectory)
17301730
}
17311731

17321732
if (SUCCESS != object_init_ex(&iter, spl_ce_RecursiveDirectoryIterator)) {
1733-
zval_ptr_dtor(&iter);
17341733
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname);
17351734
RETURN_THROWS();
17361735
}
@@ -1748,7 +1747,6 @@ PHP_METHOD(Phar, buildFromDirectory)
17481747

17491748
if (SUCCESS != object_init_ex(&iteriter, spl_ce_RecursiveIteratorIterator)) {
17501749
zval_ptr_dtor(&iter);
1751-
zval_ptr_dtor(&iteriter);
17521750
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname);
17531751
RETURN_THROWS();
17541752
}
@@ -1769,7 +1767,6 @@ PHP_METHOD(Phar, buildFromDirectory)
17691767

17701768
if (SUCCESS != object_init_ex(&regexiter, spl_ce_RegexIterator)) {
17711769
zval_ptr_dtor(&iteriter);
1772-
zval_ptr_dtor(&regexiter);
17731770
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate regex iterator for %s", phar_obj->archive->fname);
17741771
RETURN_THROWS();
17751772
}
@@ -2200,9 +2197,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /*
22002197
ce = phar_ce_archive;
22012198
}
22022199

2203-
ZVAL_NULL(&ret);
22042200
if (SUCCESS != object_init_ex(&ret, ce)) {
2205-
zval_ptr_dtor(&ret);
22062201
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname);
22072202
return NULL;
22082203
}

0 commit comments

Comments
 (0)