From aba3ef5a9672be92d09ac7d6bb0593584b2aca27 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 12 Oct 2025 14:43:50 +0200 Subject: [PATCH] phar: Remove confusing dtor calls 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 23823a1f2644e..8936198c00129 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1729,7 +1729,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(); } @@ -1747,7 +1746,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(); } @@ -1768,7 +1766,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(); } @@ -2199,9 +2196,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* 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; }