Skip to content

Fix efree target from error to *error - #25376

Closed
matyapiro31 wants to merge 1 commit into
php:PHP-8.4from
matyapiro31:patch-1
Closed

matyapiro31 wants to merge 1 commit into
php:PHP-8.4from
matyapiro31:patch-1

Conversation

@matyapiro31

Copy link
Copy Markdown
Contributor

error is defined as char **, so in this line, free *error is correct and insert NULL after free.

This error if statement is dead non-reachable code.

error is defined as char **, so in this line, free *error is correct and insert NULL after free.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be simplified on master as you cannot have a non null phar pointer and an error at the same time.

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I will remove it when merging to master

diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index bee5fe7..53691be 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -489,7 +489,6 @@ static zend_result phar_open_parsed_phar(
 	size_t fname_len,
 	/* copyable & hash update */ zend_string *alias,
 	bool is_data,
-	uint32_t options,
 	phar_archive_data** pphar,
 	char **error
 ) {
@@ -554,10 +553,6 @@ static zend_result phar_open_parsed_phar(
 			*pphar = NULL;
 		}
 
-		if (phar && error && !(options & REPORT_ERRORS)) {
-			efree(error);
-		}
-
 		return FAILURE;
 	}
 }
@@ -1344,7 +1339,7 @@
 		return FAILURE;
 	}
 check_file:
-	if (phar_open_parsed_phar(ZSTR_VAL(fname), ZSTR_LEN(fname), alias, is_data, options, test, &my_error) == SUCCESS) {
+	if (phar_open_parsed_phar(ZSTR_VAL(fname), ZSTR_LEN(fname), alias, is_data, test, &my_error) == SUCCESS) {
 		*pphar = *test;
 
 		if ((*test)->is_data && !(*test)->is_tar && !(*test)->is_zip) {
@@ -1546,7 +1541,7 @@
 		is_data = true;
 	}
 
-	if (phar_open_parsed_phar(fname, fname_len, alias, is_data, options, pphar, error) == SUCCESS) {
+	if (phar_open_parsed_phar(fname, fname_len, alias, is_data, pphar, error) == SUCCESS) {
 		return SUCCESS;
 	} else if (error && *error) {
 		return FAILURE;
@@ -2295,7 +2290,7 @@
 		return FAILURE;
 	}
 
-	if (phar_open_parsed_phar(ZSTR_VAL(fname), ZSTR_LEN(fname), alias, false, REPORT_ERRORS, NULL, NULL) == SUCCESS) {
+	if (phar_open_parsed_phar(ZSTR_VAL(fname), ZSTR_LEN(fname), alias, false, NULL, NULL) == SUCCESS) {
 		return SUCCESS;
 	}
 

LamentXU123 added a commit that referenced this pull request Nov 11, 2026
On master, remove the obsolete error cleanup and its unused options
parameter. phar_get_archive() returns NULL on errors, so a returned
archive has no error message to free.

* PHP-8.6:
  Fix error buffer cleanup in phar_open_parsed_phar() (#25376)
@LamentXU123

Copy link
Copy Markdown
Member

Thanks

t0ny4 pushed a commit to t0ny4/php-src that referenced this pull request Nov 11, 2026
* PHP-8.4:
  Fix error buffer cleanup in phar_open_parsed_phar() (php#25376)
t0ny4 pushed a commit to t0ny4/php-src that referenced this pull request Nov 11, 2026
* PHP-8.5:
  Fix error buffer cleanup in phar_open_parsed_phar() (php#25376)
arnaud-lb added a commit to jorgsowa/php-src that referenced this pull request Nov 11, 2026
* PHP-8.6:
  Fix error buffer cleanup in phar_open_parsed_phar() (php#25376)
  Fix phpGH-25306: Assertion status == LXB_STATUS_OK in dom_parse_selector when lexbor allocation fails
  Fix AST printing dropping readonly on promoted parameters (phpGH-25207)
  Fix truncated anonymous class names in error messages and logs (phpGH-25352)
  ext/gd: blame the points array when a polygon has too few points
  ext/gd: keep the brush and tile images alive while the destination uses them
  ext/standard/dns.c: drop partially built records in php_parserr()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants