mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17808: PharFileInfo refcount bug
This commit is contained in:
commit
c7d62cfd76
2 changed files with 34 additions and 2 deletions
|
@ -4504,6 +4504,9 @@ PHP_METHOD(PharFileInfo, __construct)
|
||||||
efree(entry);
|
efree(entry);
|
||||||
|
|
||||||
entry_obj->entry = entry_info;
|
entry_obj->entry = entry_info;
|
||||||
|
if (!entry_info->is_persistent && !entry_info->is_temp_dir) {
|
||||||
|
++entry_info->fp_refcount;
|
||||||
|
}
|
||||||
|
|
||||||
ZVAL_STRINGL(&arg1, fname, fname_len);
|
ZVAL_STRINGL(&arg1, fname, fname_len);
|
||||||
|
|
||||||
|
@ -4533,15 +4536,23 @@ PHP_METHOD(PharFileInfo, __destruct)
|
||||||
RETURN_THROWS();
|
RETURN_THROWS();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry_obj->entry && entry_obj->entry->is_temp_dir) {
|
if (!entry_obj->entry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry_obj->entry->is_temp_dir) {
|
||||||
if (entry_obj->entry->filename) {
|
if (entry_obj->entry->filename) {
|
||||||
zend_string_efree(entry_obj->entry->filename);
|
zend_string_efree(entry_obj->entry->filename);
|
||||||
entry_obj->entry->filename = NULL;
|
entry_obj->entry->filename = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
efree(entry_obj->entry);
|
efree(entry_obj->entry);
|
||||||
entry_obj->entry = NULL;
|
} else if (!entry_obj->entry->is_persistent) {
|
||||||
|
--entry_obj->entry->fp_refcount;
|
||||||
|
/* It is necessarily still in the manifest, which will ultimately free this. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entry_obj->entry = NULL;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
21
ext/phar/tests/gh17808.phpt
Normal file
21
ext/phar/tests/gh17808.phpt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
--TEST--
|
||||||
|
GH-17808 (PharFileInfo refcount bug)
|
||||||
|
--EXTENSIONS--
|
||||||
|
phar
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$fname = __DIR__.'/tar/files/Structures_Graph-1.0.3.tgz';
|
||||||
|
$tar = new PharData($fname);
|
||||||
|
foreach (new RecursiveIteratorIterator($tar) as $file) {
|
||||||
|
}
|
||||||
|
var_dump("$file");
|
||||||
|
var_dump(strlen($file->getContent()));
|
||||||
|
unlink("$file");
|
||||||
|
var_dump($file->getATime());
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(%d) "phar://%spackage.xml"
|
||||||
|
int(6747)
|
||||||
|
|
||||||
|
Warning: unlink(): phar error: "package.xml" in phar %s, has open file pointers, cannot unlink in %s on line %d
|
||||||
|
int(33188)
|
Loading…
Add table
Add a link
Reference in a new issue