Skip to content

Commit 7d166a2

Browse files
authored
ext/phar: no need to free error if operation is successful (php#21859)
This could also be seen from the lack of coverage on CodeCov as these are impossible branches to reach.
1 parent 3433bd5 commit 7d166a2

3 files changed

Lines changed: 0 additions & 21 deletions

File tree

ext/phar/dirstream.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,6 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
287287
return NULL;
288288
}
289289

290-
if (error) {
291-
efree(error);
292-
}
293-
294290
if (zend_string_equals(resource->path, ZSTR_CHAR('/'))) {
295291
/* root directory requested */
296292
php_url_free(resource);

ext/phar/phar_object.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,9 +1655,6 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
16551655
return ZEND_HASH_APPLY_STOP;
16561656

16571657
} else {
1658-
if (error) {
1659-
efree(error);
1660-
}
16611658
/* convert to PHAR_UFP */
16621659
if (data->internal_file->fp_type == PHAR_MOD) {
16631660
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
36033600
}
36043601
goto finish;
36053602
} else {
3606-
if (error) {
3607-
efree(error);
3608-
}
3609-
36103603
if (!data->internal_file->is_dir) {
36113604
size_t contents_len = 0;
36123605
if (content) {
@@ -3683,10 +3676,6 @@ static void phar_mkdir(phar_archive_data **pphar, zend_string *dir_name)
36833676

36843677
return;
36853678
} else {
3686-
if (error) {
3687-
efree(error);
3688-
}
3689-
36903679
/* check for copy on write */
36913680
if (data->phar != *pphar) {
36923681
*pphar = data->phar;

ext/phar/stream.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
200200
php_url_free(resource);
201201
return NULL;
202202
}
203-
if (error) {
204-
efree(error);
205-
}
206203
fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
207204
php_url_free(resource);
208205
efree(internal_file);
@@ -706,9 +703,6 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
706703
php_url_free(resource);
707704
return 0;
708705
}
709-
if (error) {
710-
efree(error);
711-
}
712706
if (idata->internal_file->fp_refcount > 1) {
713707
/* more than just our fp resource is open for this file */
714708
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));

0 commit comments

Comments
 (0)