@@ -4520,6 +4520,9 @@ PHP_METHOD(PharFileInfo, __construct)
45204520 entry_obj -> entry = entry_info ;
45214521 if (!entry_info -> is_persistent && !entry_info -> is_temp_dir ) {
45224522 ++ entry_info -> fp_refcount ;
4523+ /* The phar data must exist to keep the alias locked. */
4524+ ZEND_ASSERT (!phar_data -> is_persistent );
4525+ ++ phar_data -> refcount ;
45234526 }
45244527
45254528 ZVAL_STRINGL (& arg1 , fname , fname_len );
@@ -4550,23 +4553,26 @@ PHP_METHOD(PharFileInfo, __destruct)
45504553 RETURN_THROWS ();
45514554 }
45524555
4553- if (!entry_obj -> entry ) {
4556+ phar_entry_info * entry = entry_obj -> entry ;
4557+ if (!entry ) {
45544558 return ;
45554559 }
45564560
4557- if (entry_obj -> entry -> is_temp_dir ) {
4558- if (entry_obj -> entry -> filename ) {
4559- efree (entry_obj -> entry -> filename );
4560- entry_obj -> entry -> filename = NULL ;
4561+ if (entry -> is_temp_dir ) {
4562+ if (entry -> filename ) {
4563+ efree (entry -> filename );
4564+ entry -> filename = NULL ;
45614565 }
45624566
4563- efree (entry_obj -> entry );
4564- } else if (!entry_obj -> entry -> is_persistent ) {
4565- -- entry_obj -> entry -> fp_refcount ;
4566- /* It is necessarily still in the manifest, which will ultimately free this. */
4567+ efree (entry );
4568+ entry_obj -> entry = NULL ;
4569+ } else if (!entry -> is_persistent ) {
4570+ -- entry -> fp_refcount ;
4571+ /* The entry itself still lives in the manifest,
4572+ * which will either be freed here if the file info was the last reference; or freed later. */
4573+ entry_obj -> entry = NULL ;
4574+ phar_archive_delref (entry -> phar );
45674575 }
4568-
4569- entry_obj -> entry = NULL ;
45704576}
45714577/* }}} */
45724578
0 commit comments