Skip to content

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Sep 7, 2025

Discovered by coincidence while looking at #19752
If stream creation fails, we leak all the memory allocated before. If we just move the stream creation upwards we don't need special handling at all.

Comment on lines 2229 to +2236
PHAR_G(last_phar) = NULL;
PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;

php_stream *tmp_fp = php_stream_fopen_tmpfile();
if (tmp_fp == NULL) {
zend_throw_exception_ex(phar_ce_PharException, 0, "unable to create temporary file");
return NULL;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to invalidate the cache even in this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters too much, but at least this keeps the current behaviour.

@nielsdos nielsdos closed this in 98bb934 Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants