mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.2'
* PHP-7.2: Fix bug #76524 - ZipArchive memory leak
This commit is contained in:
commit
d82cb24e19
2 changed files with 26 additions and 2 deletions
|
@ -1029,10 +1029,13 @@ static void php_zip_object_free_storage(zend_object *object) /* {{{ */
|
||||||
}
|
}
|
||||||
if (intern->za) {
|
if (intern->za) {
|
||||||
if (zip_close(intern->za) != 0) {
|
if (zip_close(intern->za) != 0) {
|
||||||
|
#if LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR == 3 && LIBZIP_VERSION_MICRO == 1
|
||||||
|
php_error_docref(NULL, E_WARNING, "Cannot destroy the zip context: %s", "zip_close have failed");
|
||||||
|
#else
|
||||||
php_error_docref(NULL, E_WARNING, "Cannot destroy the zip context: %s", zip_strerror(intern->za));
|
php_error_docref(NULL, E_WARNING, "Cannot destroy the zip context: %s", zip_strerror(intern->za));
|
||||||
return;
|
zip_discard(intern->za);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
intern->za = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intern->buffers_cnt>0) {
|
if (intern->buffers_cnt>0) {
|
||||||
|
|
21
ext/zip/tests/bug76524.phpt
Normal file
21
ext/zip/tests/bug76524.phpt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
--TEST--
|
||||||
|
ZipArchive Bug #76524 (memory leak with ZipArchive::OVERWRITE flag and empty archive)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(!extension_loaded('zip')) die('skip');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = __DIR__ . '/nonexistent.zip';
|
||||||
|
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||||
|
echo 'ok';
|
||||||
|
|
||||||
|
/* Zip-related error messages depend on platform and libzip version,
|
||||||
|
so the regex is used to check that Zend MM does NOT show warnings
|
||||||
|
about leaks: */
|
||||||
|
?>
|
||||||
|
--EXPECTREGEX--
|
||||||
|
ok((?!memory leaks detected).)*
|
Loading…
Add table
Add a link
Reference in a new issue