Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/phar/phar_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,7 @@ static zend_object *phar_convert_to_other(phar_archive_data *source, int convert
zend_throw_exception_ex(phar_ce_PharException, 0, "unable to create temporary file");
return NULL;
}
phar->fname = source->fname;
phar->fname = estrndup(source->fname, source->fname_len);
Copy link
Member Author

@krakjoe krakjoe Sep 7, 2025

Choose a reason for hiding this comment

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

maybe expect pestrndup, it is not necessary because the new phar object is calloced (so is_persistent is set 0), so that when phar_destroy_phar_data executes the string will be efree'd correctly.

phar->fname_len = source->fname_len;
phar->is_temporary_alias = source->is_temporary_alias;
phar->alias = source->alias;
Expand Down
16 changes: 16 additions & 0 deletions ext/phar/tests/gh19752.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-19752 (missing dup in phar_convert_to_other)
--EXTENSIONS--
phar
--FILE--
<?php
$phar = new PharData('test.1');

try {
$phar->decompress("*");
} catch (Exception $ex) {
var_dump($ex->getMessage());
}
?>
--EXPECTF--
string(%d) "data phar converted from "%stest.1" has invalid extension *"
Loading