@@ -1004,10 +1004,23 @@ static void php_zip_cancel_callback_free(void *ptr)
10041004}
10051005#endif
10061006
1007- static void php_zip_object_dtor (zend_object * object ) /* {{{ */
1007+ static void php_zip_object_dtor (zend_object * object )
10081008{
10091009 zend_objects_destroy_object (object );
10101010
1011+ ze_zip_object * intern = php_zip_fetch_object (object );
1012+
1013+ if (intern -> za ) {
1014+ if (zip_close (intern -> za ) != 0 ) {
1015+ php_error_docref (NULL , E_WARNING , "Cannot destroy the zip context: %s" , zip_strerror (intern -> za ));
1016+ zip_discard (intern -> za );
1017+ }
1018+ intern -> za = NULL ;
1019+ }
1020+ }
1021+
1022+ static void php_zip_object_free_storage (zend_object * object ) /* {{{ */
1023+ {
10111024 ze_zip_object * intern = php_zip_fetch_object (object );
10121025 int i ;
10131026
@@ -1036,6 +1049,7 @@ static void php_zip_object_dtor(zend_object *object) /* {{{ */
10361049#endif
10371050
10381051 intern -> za = NULL ;
1052+ zend_object_std_dtor (& intern -> zo );
10391053
10401054 if (intern -> filename ) {
10411055 efree (intern -> filename );
@@ -2988,6 +3002,10 @@ PHP_METHOD(ZipArchive, getStream)
29883002#ifdef HAVE_PROGRESS_CALLBACK
29893003static void php_zip_progress_callback (zip_t * arch , double state , void * ptr )
29903004{
3005+ if (!EG (active )) {
3006+ return ;
3007+ }
3008+
29913009 zval cb_args [1 ];
29923010 ze_zip_object * obj = ptr ;
29933011
@@ -3034,6 +3052,10 @@ static int php_zip_cancel_callback(zip_t *arch, void *ptr)
30343052 zval cb_retval ;
30353053 ze_zip_object * obj = ptr ;
30363054
3055+ if (!EG (active )) {
3056+ return 0 ;
3057+ }
3058+
30373059 zend_call_known_fcc (& obj -> cancel_callback , & cb_retval , 0 , NULL , NULL );
30383060 if (Z_ISUNDEF (cb_retval )) {
30393061 /* Cancel if an exception has been thrown */
@@ -3120,6 +3142,7 @@ static PHP_MINIT_FUNCTION(zip)
31203142{
31213143 memcpy (& zip_object_handlers , & std_object_handlers , sizeof (zend_object_handlers ));
31223144 zip_object_handlers .offset = XtOffsetOf (ze_zip_object , zo );
3145+ zip_object_handlers .free_obj = php_zip_object_free_storage ;
31233146 zip_object_handlers .dtor_obj = php_zip_object_dtor ;
31243147 zip_object_handlers .clone_obj = NULL ;
31253148 zip_object_handlers .get_property_ptr_ptr = php_zip_get_property_ptr_ptr ;
0 commit comments