File tree 2 files changed +34
-2
lines changed
2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -4504,6 +4504,9 @@ PHP_METHOD(PharFileInfo, __construct)
4504
4504
efree (entry );
4505
4505
4506
4506
entry_obj -> entry = entry_info ;
4507
+ if (!entry_info -> is_persistent && !entry_info -> is_temp_dir ) {
4508
+ ++ entry_info -> fp_refcount ;
4509
+ }
4507
4510
4508
4511
ZVAL_STRINGL (& arg1 , fname , fname_len );
4509
4512
@@ -4533,15 +4536,23 @@ PHP_METHOD(PharFileInfo, __destruct)
4533
4536
RETURN_THROWS ();
4534
4537
}
4535
4538
4536
- if (entry_obj -> entry && entry_obj -> entry -> is_temp_dir ) {
4539
+ if (!entry_obj -> entry ) {
4540
+ return ;
4541
+ }
4542
+
4543
+ if (entry_obj -> entry -> is_temp_dir ) {
4537
4544
if (entry_obj -> entry -> filename ) {
4538
4545
zend_string_efree (entry_obj -> entry -> filename );
4539
4546
entry_obj -> entry -> filename = NULL ;
4540
4547
}
4541
4548
4542
4549
efree (entry_obj -> entry );
4543
- entry_obj -> entry = NULL ;
4550
+ } else if (!entry_obj -> entry -> is_persistent ) {
4551
+ -- entry_obj -> entry -> fp_refcount ;
4552
+ /* It is necessarily still in the manifest, which will ultimately free this. */
4544
4553
}
4554
+
4555
+ entry_obj -> entry = NULL ;
4545
4556
}
4546
4557
/* }}} */
4547
4558
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-17808 (PharFileInfo refcount bug)
3
+ --EXTENSIONS--
4
+ phar
5
+ --FILE--
6
+ <?php
7
+ $ fname = __DIR__ .'/tar/files/Structures_Graph-1.0.3.tgz ' ;
8
+ $ tar = new PharData ($ fname );
9
+ foreach (new RecursiveIteratorIterator ($ tar ) as $ file ) {
10
+ }
11
+ var_dump ("$ file " );
12
+ var_dump (strlen ($ file ->getContent ()));
13
+ unlink ("$ file " );
14
+ var_dump ($ file ->getATime ());
15
+ ?>
16
+ --EXPECTF--
17
+ string(%d) "phar://%spackage.xml"
18
+ int(6747)
19
+
20
+ Warning: unlink(): phar error: "package.xml" in phar %s, has open file pointers, cannot unlink in %s on line %d
21
+ int(33188)
You can’t perform that action at this time.
0 commit comments