Skip to content

Commit 6563ae2

Browse files
committed
ext/phar: pass NULL pointer for error instead of freeing it immediately
This is effectively doing unnecessary allocations for no good reason.
1 parent 34a9274 commit 6563ae2

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

ext/phar/stream.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -742,11 +742,8 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
742742
php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_from);
743743
return 0;
744744
}
745-
if (SUCCESS != phar_get_archive(&pfrom, ZSTR_VAL(resource_from->host), ZSTR_LEN(resource_from->host), NULL, 0, &error)) {
745+
if (SUCCESS != phar_get_archive(&pfrom, ZSTR_VAL(resource_from->host), ZSTR_LEN(resource_from->host), NULL, 0, NULL)) {
746746
pfrom = NULL;
747-
if (error) {
748-
efree(error);
749-
}
750747
}
751748
if (PHAR_G(readonly) && (!pfrom || !pfrom->is_data)) {
752749
php_url_free(resource_from);
@@ -760,10 +757,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
760757
php_error_docref(NULL, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"", url_from, url_to, url_to);
761758
return 0;
762759
}
763-
if (SUCCESS != phar_get_archive(&pto, ZSTR_VAL(resource_to->host), ZSTR_LEN(resource_to->host), NULL, 0, &error)) {
764-
if (error) {
765-
efree(error);
766-
}
760+
if (SUCCESS != phar_get_archive(&pto, ZSTR_VAL(resource_to->host), ZSTR_LEN(resource_to->host), NULL, 0, NULL)) {
767761
pto = NULL;
768762
}
769763
if (PHAR_G(readonly) && (!pto || !pto->is_data)) {

0 commit comments

Comments
 (0)