diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 97a12dd4d56..1c2e4304858 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -3050,14 +3050,11 @@ PHP_METHOD(ZipArchive, registerProgressCallback) RETURN_THROWS(); } - /* free if called twice */ - php_zip_progress_callback_free(obj); - /* register */ - zend_fcc_dup(&obj->progress_callback, &fcc); if (zip_register_progress_callback_with_state(intern, rate, php_zip_progress_callback, php_zip_progress_callback_free, obj)) { RETURN_FALSE; } + zend_fcc_dup(&obj->progress_callback, &fcc); RETURN_TRUE; } @@ -3108,14 +3105,11 @@ PHP_METHOD(ZipArchive, registerCancelCallback) RETURN_THROWS(); } - /* free if called twice */ - php_zip_cancel_callback_free(obj); - /* register */ - zend_fcc_dup(&obj->cancel_callback, &fcc); if (zip_register_cancel_callback_with_state(intern, php_zip_cancel_callback, php_zip_cancel_callback_free, obj)) { RETURN_FALSE; } + zend_fcc_dup(&obj->cancel_callback, &fcc); RETURN_TRUE; } diff --git a/ext/zip/tests/gh18431.phpt b/ext/zip/tests/gh18431.phpt new file mode 100644 index 00000000000..d4eb89c36c6 --- /dev/null +++ b/ext/zip/tests/gh18431.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-18431 (Registering ZIP progress callback twice doesn't work) +--EXTENSIONS-- +zip +--FILE-- +open($file, ZIPARCHIVE::CREATE); +$zip->registerProgressCallback(0.5, $callback); +$zip->registerProgressCallback(0.5, $callback); +$zip->addFromString('foo', 'entry #1'); +?> +--CLEAN-- + +--EXPECT-- +float(0) +float(1)