From 29d6e29216740ce10c9876daaa6adf919773d81b Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 12 Oct 2025 23:45:00 +0200 Subject: [PATCH] phar: Remove confusing dtor calls (#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. --- ext/phar/phar_object.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 92d96eebe4b..f4950350062 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1730,7 +1730,6 @@ PHP_METHOD(Phar, buildFromDirectory) } if (SUCCESS != object_init_ex(&iter, spl_ce_RecursiveDirectoryIterator)) { - zval_ptr_dtor(&iter); zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname); RETURN_THROWS(); } @@ -1748,7 +1747,6 @@ PHP_METHOD(Phar, buildFromDirectory) if (SUCCESS != object_init_ex(&iteriter, spl_ce_RecursiveIteratorIterator)) { zval_ptr_dtor(&iter); - zval_ptr_dtor(&iteriter); zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname); RETURN_THROWS(); } @@ -1769,7 +1767,6 @@ PHP_METHOD(Phar, buildFromDirectory) if (SUCCESS != object_init_ex(®exiter, spl_ce_RegexIterator)) { zval_ptr_dtor(&iteriter); - zval_ptr_dtor(®exiter); zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate regex iterator for %s", phar_obj->archive->fname); RETURN_THROWS(); } @@ -2200,9 +2197,7 @@ its_ok: ce = phar_ce_archive; } - ZVAL_NULL(&ret); if (SUCCESS != object_init_ex(&ret, ce)) { - zval_ptr_dtor(&ret); zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname); return NULL; }