From 69abe17ade3f23ab1e8d77b9f254d0cfc9d637b5 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 23 Apr 2026 21:49:56 +0100 Subject: [PATCH] ext/phar: no need to free error if operation is successful --- ext/phar/dirstream.c | 4 ---- ext/phar/phar_object.c | 11 ----------- ext/phar/stream.c | 6 ------ 3 files changed, 21 deletions(-) diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index bdd90851fecc..4bef14dfe6ae 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -287,10 +287,6 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, return NULL; } - if (error) { - efree(error); - } - if (zend_string_equals(resource->path, ZSTR_CHAR('/'))) { /* root directory requested */ php_url_free(resource); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index c07ff93b951f..bc55c175f7ba 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1655,9 +1655,6 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ return ZEND_HASH_APPLY_STOP; } else { - if (error) { - efree(error); - } /* convert to PHAR_UFP */ if (data->internal_file->fp_type == PHAR_MOD) { php_stream_close(data->internal_file->fp); @@ -3603,10 +3600,6 @@ static void phar_add_file(phar_archive_data **pphar, zend_string *file_name, con } goto finish; } else { - if (error) { - efree(error); - } - if (!data->internal_file->is_dir) { size_t contents_len = 0; if (content) { @@ -3683,10 +3676,6 @@ static void phar_mkdir(phar_archive_data **pphar, zend_string *dir_name) return; } else { - if (error) { - efree(error); - } - /* check for copy on write */ if (data->phar != *pphar) { *pphar = data->phar; diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 1d9229c44621..f49bc5e2deba 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -200,9 +200,6 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha php_url_free(resource); return NULL; } - if (error) { - efree(error); - } fpf = php_stream_alloc(&phar_ops, idata, NULL, mode); php_url_free(resource); efree(internal_file); @@ -706,9 +703,6 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int php_url_free(resource); return 0; } - if (error) { - efree(error); - } if (idata->internal_file->fp_refcount > 1) { /* more than just our fp resource is open for this file */ php_stream_wrapper_log_error(wrapper, options, "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot unlink", internal_file, ZSTR_VAL(resource->host));