@@ -1030,13 +1030,12 @@ static void php_zip_progress_callback_free(void *ptr)
10301030#endif
10311031
10321032#ifdef HAVE_CANCEL_CALLBACK
1033- static void _php_zip_cancel_callback_free (void * ptr )
1033+ static void php_zip_cancel_callback_free (void * ptr )
10341034{
10351035 ze_zip_object * obj = ptr ;
10361036
1037- if (!Z_ISUNDEF (obj -> cancel_callback )) {
1038- zval_ptr_dtor (& obj -> cancel_callback );
1039- ZVAL_UNDEF (& obj -> cancel_callback );
1037+ if (ZEND_FCC_INITIALIZED (obj -> cancel_callback )) {
1038+ zend_fcc_dtor (& obj -> cancel_callback );
10401039 }
10411040}
10421041#endif
@@ -1070,7 +1069,7 @@ static void php_zip_object_free_storage(zend_object *object) /* {{{ */
10701069
10711070#ifdef HAVE_CANCEL_CALLBACK
10721071 /* if not properly called by libzip */
1073- _php_zip_cancel_callback_free (intern );
1072+ php_zip_cancel_callback_free (intern );
10741073#endif
10751074
10761075 intern -> za = NULL ;
@@ -3064,13 +3063,14 @@ PHP_METHOD(ZipArchive, registerProgressCallback)
30643063#endif
30653064
30663065#ifdef HAVE_CANCEL_CALLBACK
3067- static int _php_zip_cancel_callback (zip_t * arch , void * ptr )
3066+ static int php_zip_cancel_callback (zip_t * arch , void * ptr )
30683067{
30693068 zval cb_retval ;
30703069 int retval = 0 ;
30713070 ze_zip_object * obj = ptr ;
30723071
3073- if (call_user_function (EG (function_table ), NULL , & obj -> cancel_callback , & cb_retval , 0 , NULL ) == SUCCESS && !Z_ISUNDEF (cb_retval )) {
3072+ zend_call_known_fcc (& obj -> cancel_callback , & cb_retval , 0 , NULL , NULL );
3073+ if (!Z_ISUNDEF (cb_retval )) {
30743074 retval = zval_get_long (& cb_retval );
30753075 zval_ptr_dtor (& cb_retval );
30763076 }
@@ -3082,24 +3082,28 @@ static int _php_zip_cancel_callback(zip_t *arch, void *ptr)
30823082PHP_METHOD (ZipArchive , registerCancelCallback )
30833083{
30843084 struct zip * intern ;
3085- zval * self = ZEND_THIS ;
3086- zend_fcall_info fci ;
3085+ zend_fcall_info dummy_fci ;
30873086 zend_fcall_info_cache fcc ;
30883087 ze_zip_object * obj ;
3089- if (zend_parse_parameters (ZEND_NUM_ARGS (), "f " , & fci , & fcc ) == FAILURE ) {
3088+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "F " , & dummy_fci , & fcc ) == FAILURE ) {
30903089 RETURN_THROWS ();
30913090 }
30923091
3093- ZIP_FROM_OBJECT (intern , self );
3094-
3095- obj = Z_ZIP_P (self );
3092+ /* Inline ZIP_FROM_OBJECT(intern, self); */
3093+ obj = Z_ZIP_P (ZEND_THIS );
3094+ intern = obj -> za ;
3095+ if (!intern ) { \
3096+ zend_value_error ("Invalid or uninitialized Zip object" );
3097+ zend_release_fcall_info_cache (& fcc );
3098+ RETURN_THROWS ();
3099+ }
30963100
30973101 /* free if called twice */
3098- _php_zip_cancel_callback_free (obj );
3102+ php_zip_cancel_callback_free (obj );
30993103
31003104 /* register */
3101- ZVAL_COPY (& obj -> cancel_callback , & fci . function_name );
3102- if (zip_register_cancel_callback_with_state (intern , _php_zip_cancel_callback , _php_zip_cancel_callback_free , obj )) {
3105+ zend_fcc_dup (& obj -> cancel_callback , & fcc );
3106+ if (zip_register_cancel_callback_with_state (intern , php_zip_cancel_callback , php_zip_cancel_callback_free , obj )) {
31033107 RETURN_FALSE ;
31043108 }
31053109
0 commit comments