mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
fix a few memleaks and double-free()s on error conditions
This commit is contained in:
parent
9b253882fc
commit
3eaf46af3e
1 changed files with 9 additions and 3 deletions
|
@ -551,7 +551,9 @@ static void php_zip_free_dir(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
|||
|
||||
if (zip_int) {
|
||||
if (zip_int->za) {
|
||||
zip_close(zip_int->za);
|
||||
if (zip_close(zip_int->za) != 0) {
|
||||
_zip_free(zip_int->za);
|
||||
}
|
||||
zip_int->za = NULL;
|
||||
}
|
||||
|
||||
|
@ -906,16 +908,20 @@ static ZIPARCHIVE_METHOD(open)
|
|||
|
||||
if (ze_obj->za) {
|
||||
/* we already have an opened zip, free it */
|
||||
zip_close(ze_obj->za);
|
||||
if (zip_close(ze_obj->za) != 0) {
|
||||
_zip_free(ze_obj->za);
|
||||
}
|
||||
ze_obj->za = NULL;
|
||||
}
|
||||
if (ze_obj->filename) {
|
||||
efree(ze_obj->filename);
|
||||
ze_obj->filename = NULL;
|
||||
}
|
||||
intern = zip_open(resolved_path, flags, &err);
|
||||
if (!intern || err) {
|
||||
RETURN_LONG((long)err);
|
||||
}
|
||||
ze_obj->filename = estrndup(resolved_path, strlen(resolved_path));
|
||||
ze_obj->filename = estrdup(resolved_path);
|
||||
ze_obj->filename_len = filename_len;
|
||||
ze_obj->za = intern;
|
||||
RETURN_TRUE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue