File tree 3 files changed +37
-2
lines changed
3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ PHP NEWS
49
49
. Fixed bug GH-17747 (Exception on reading property in register-based
50
50
FETCH_OBJ_R breaks JIT). (Dmitry, nielsdos)
51
51
52
+ - Phar:
53
+ . Fixed bug GH-17808: PharFileInfo refcount bug. (nielsdos)
54
+
52
55
- PHPDBG:
53
56
. Partially fixed bug GH-17387 (Trivial crash in phpdbg lexer). (nielsdos)
54
57
. Fix memory leak in phpdbg calling registered function. (nielsdos)
Original file line number Diff line number Diff line change @@ -4510,6 +4510,9 @@ PHP_METHOD(PharFileInfo, __construct)
4510
4510
efree (entry );
4511
4511
4512
4512
entry_obj -> entry = entry_info ;
4513
+ if (!entry_info -> is_persistent && !entry_info -> is_temp_dir ) {
4514
+ ++ entry_info -> fp_refcount ;
4515
+ }
4513
4516
4514
4517
ZVAL_STRINGL (& arg1 , fname , fname_len );
4515
4518
@@ -4539,15 +4542,23 @@ PHP_METHOD(PharFileInfo, __destruct)
4539
4542
RETURN_THROWS ();
4540
4543
}
4541
4544
4542
- if (entry_obj -> entry && entry_obj -> entry -> is_temp_dir ) {
4545
+ if (!entry_obj -> entry ) {
4546
+ return ;
4547
+ }
4548
+
4549
+ if (entry_obj -> entry -> is_temp_dir ) {
4543
4550
if (entry_obj -> entry -> filename ) {
4544
4551
efree (entry_obj -> entry -> filename );
4545
4552
entry_obj -> entry -> filename = NULL ;
4546
4553
}
4547
4554
4548
4555
efree (entry_obj -> entry );
4549
- entry_obj -> entry = NULL ;
4556
+ } else if (!entry_obj -> entry -> is_persistent ) {
4557
+ -- entry_obj -> entry -> fp_refcount ;
4558
+ /* It is necessarily still in the manifest, which will ultimately free this. */
4550
4559
}
4560
+
4561
+ entry_obj -> entry = NULL ;
4551
4562
}
4552
4563
/* }}} */
4553
4564
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