Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,10 @@ static void php_zip_cancel_callback_free(void *ptr)
}
#endif

static void php_zip_object_free_storage(zend_object *object) /* {{{ */
static void php_zip_object_dtor(zend_object *object) /* {{{ */
{
zend_objects_destroy_object(object);

ze_zip_object * intern = php_zip_fetch_object(object);
int i;

Expand Down Expand Up @@ -1034,7 +1036,6 @@ static void php_zip_object_free_storage(zend_object *object) /* {{{ */
#endif

intern->za = NULL;
zend_object_std_dtor(&intern->zo);

if (intern->filename) {
efree(intern->filename);
Expand Down Expand Up @@ -3119,7 +3120,7 @@ static PHP_MINIT_FUNCTION(zip)
{
memcpy(&zip_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
zip_object_handlers.offset = XtOffsetOf(ze_zip_object, zo);
zip_object_handlers.free_obj = php_zip_object_free_storage;
zip_object_handlers.dtor_obj = php_zip_object_dtor;
zip_object_handlers.clone_obj = NULL;
zip_object_handlers.get_property_ptr_ptr = php_zip_get_property_ptr_ptr;

Expand Down
28 changes: 28 additions & 0 deletions ext/zip/tests/ZipArchive_bailout.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
ZipArchive destructor should be called on bailout
--EXTENSIONS--
zip
--FILE--
<?php

function &cb() {}

$file = __DIR__ . '/gh18907.zip';
$zip = new ZipArchive;
$zip->open($file, ZIPARCHIVE::CREATE);
$zip->registerCancelCallback(cb(...));
$zip->addFromString('test', 'test');
$fusion = $zip;

?>
--CLEAN--
<?php
$file = __DIR__ . '/gh18907.zip';
@unlink($file);
?>
--EXPECTF--
Notice: Only variable references should be returned by reference in %s on line %d

Notice: Only variable references should be returned by reference in %s on line %d

Notice: Only variable references should be returned by reference in %s on line %d