@@ -4514,6 +4514,9 @@ PHP_METHOD(PharFileInfo, __construct)
45144514	entry_obj -> entry  =  entry_info ;
45154515	if  (!entry_info -> is_persistent  &&  !entry_info -> is_temp_dir ) {
45164516		++ entry_info -> fp_refcount ;
4517+ 		/* The phar data must exist to keep the alias locked. */ 
4518+ 		ZEND_ASSERT (!phar_data -> is_persistent );
4519+ 		++ phar_data -> refcount ;
45174520	}
45184521
45194522	ZVAL_STRINGL (& arg1 , fname , fname_len );
@@ -4544,23 +4547,26 @@ PHP_METHOD(PharFileInfo, __destruct)
45444547		RETURN_THROWS ();
45454548	}
45464549
4547- 	if  (!entry_obj -> entry ) {
4550+ 	phar_entry_info  * entry  =  entry_obj -> entry ;
4551+ 	if  (!entry ) {
45484552		return ;
45494553	}
45504554
4551- 	if  (entry_obj -> entry -> is_temp_dir ) {
4552- 		if  (entry_obj -> entry -> filename ) {
4553- 			zend_string_efree ( entry_obj -> entry -> filename );
4554- 			entry_obj -> entry -> filename  =  NULL ;
4555+ 	if  (entry -> is_temp_dir ) {
4556+ 		if  (entry -> filename ) {
4557+ 			zend_string_release_ex ( entry -> filename , false );
4558+ 			entry -> filename  =  NULL ;
45554559		}
45564560
4557- 		efree (entry_obj -> entry );
4558- 	} else  if  (!entry_obj -> entry -> is_persistent ) {
4559- 		-- entry_obj -> entry -> fp_refcount ;
4560- 		/* It is necessarily still in the manifest, which will ultimately free this. */ 
4561+ 		efree (entry );
4562+ 		entry_obj -> entry  =  NULL ;
4563+ 	} else  if  (!entry -> is_persistent ) {
4564+ 		-- entry -> fp_refcount ;
4565+ 		/* The entry itself still lives in the manifest, 
4566+ 		 * which will either be freed here if the file info was the last reference; or freed later. */ 
4567+ 		entry_obj -> entry  =  NULL ;
4568+ 		phar_archive_delref (entry -> phar );
45614569	}
4562- 
4563- 	entry_obj -> entry  =  NULL ;
45644570}
45654571/* }}} */ 
45664572
0 commit comments