@@ -1004,10 +1004,23 @@ static void php_zip_cancel_callback_free(void *ptr)
1004
1004
}
1005
1005
#endif
1006
1006
1007
- static void php_zip_object_dtor (zend_object * object ) /* {{{ */
1007
+ static void php_zip_object_dtor (zend_object * object )
1008
1008
{
1009
1009
zend_objects_destroy_object (object );
1010
1010
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
+ {
1011
1024
ze_zip_object * intern = php_zip_fetch_object (object );
1012
1025
int i ;
1013
1026
@@ -1036,6 +1049,7 @@ static void php_zip_object_dtor(zend_object *object) /* {{{ */
1036
1049
#endif
1037
1050
1038
1051
intern -> za = NULL ;
1052
+ zend_object_std_dtor (& intern -> zo );
1039
1053
1040
1054
if (intern -> filename ) {
1041
1055
efree (intern -> filename );
@@ -2988,6 +3002,10 @@ PHP_METHOD(ZipArchive, getStream)
2988
3002
#ifdef HAVE_PROGRESS_CALLBACK
2989
3003
static void php_zip_progress_callback (zip_t * arch , double state , void * ptr )
2990
3004
{
3005
+ if (!EG (active )) {
3006
+ return ;
3007
+ }
3008
+
2991
3009
zval cb_args [1 ];
2992
3010
ze_zip_object * obj = ptr ;
2993
3011
@@ -3034,6 +3052,10 @@ static int php_zip_cancel_callback(zip_t *arch, void *ptr)
3034
3052
zval cb_retval ;
3035
3053
ze_zip_object * obj = ptr ;
3036
3054
3055
+ if (!EG (active )) {
3056
+ return 0 ;
3057
+ }
3058
+
3037
3059
zend_call_known_fcc (& obj -> cancel_callback , & cb_retval , 0 , NULL , NULL );
3038
3060
if (Z_ISUNDEF (cb_retval )) {
3039
3061
/* Cancel if an exception has been thrown */
@@ -3120,6 +3142,7 @@ static PHP_MINIT_FUNCTION(zip)
3120
3142
{
3121
3143
memcpy (& zip_object_handlers , & std_object_handlers , sizeof (zend_object_handlers ));
3122
3144
zip_object_handlers .offset = XtOffsetOf (ze_zip_object , zo );
3145
+ zip_object_handlers .free_obj = php_zip_object_free_storage ;
3123
3146
zip_object_handlers .dtor_obj = php_zip_object_dtor ;
3124
3147
zip_object_handlers .clone_obj = NULL ;
3125
3148
zip_object_handlers .get_property_ptr_ptr = php_zip_get_property_ptr_ptr ;
0 commit comments