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()
@matyapiro31
matyapiro31 deleted the patch-1 branch November 12, 2026 14:28
arnaud-lb added a commit to pavimus/php-src that referenced this pull request Nov 16, 2026
* PHP-8.4: (262 commits)
  Fix phpGH-25474: version_compare() numeric parts overflow long on Windows (php#25475)
  ext/session: prevent creation of fixed sid in php_session_rfc1867 (phpGH-22113)
  Forbid \C in patterns enabling UTF mode with (*UTF) (phpGH-25452)
  Fix phpGH-24743: var_export() ignores exception from lazy object init (php#24746)
  ext/snmp: Copy the context name in SNMP::setSecurity()
  Fix phpGH-25434: C14NFile() skips namespace relinking on success
  Fix uploaded files leak in request_parse_body() (php#25387)
  Fix phpGH-25094: NULL dereference in SOAP get_doc_function() with missing parts
  Pin Linux x86 CI to Ubuntu 24.04 (php#25416)
  Fix phpGH-25359: tracing JIT drops reference type of a named by-ref argument
  Fix AST export of by-reference property hooks (phpGH-25069)
  fix test when tmp-php.ini is used
  Fix stack overflow in filter_var() and filter_var_array() (php#25349)
  Align the Windows OPcache JIT buffer (php#25262)
  Fix phpGH-25311: Assertion ret == SUCCESS in array_map()/array_filter() after delayed out-of-memory
  Fix tracing JIT reading the int result of ++/-- on a reference as a double
  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)
  ext/gd: blame the points array when a polygon has too few points
  ...
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