Commit b8c3bf91a21 for php.net
commit b8c3bf91a21727236be1f3da400663c2c07d6014
Author: Gina Peter Banyard <girgias@php.net>
Date: Wed Apr 15 12:35:37 2026 +0100
ext/phar: Drop unnecessary Windows code as filepath is already unixied. (#21764)
This code is effectively doing an unnecessary allocation and work that has already been done.
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index b5cd3cbba43..02a2f09f952 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -2217,21 +2217,12 @@ zend_result phar_split_fname(const char *filename, size_t filename_len, char **a
if (entry) {
if (ext_str[ext_len]) {
size_t computed_entry_len = filename_len - *arch_len;
-#ifdef PHP_WIN32
- /* TODO: can we handle the unixify path in phar_fix_filepath() directly ? */
- char *fixed_path_for_windows = estrndup(ext_str+ext_len, computed_entry_len);
- phar_unixify_path_separators(fixed_path_for_windows, computed_entry_len);
- zend_string *entry_str = phar_fix_filepath(fixed_path_for_windows, computed_entry_len, false);
- *entry = estrndup(ZSTR_VAL(entry_str), ZSTR_LEN(entry_str));
- *entry_len = ZSTR_LEN(entry_str);
- zend_string_release_ex(entry_str, false);
- efree(fixed_path_for_windows);
-#else
+ /* We don't need to unixify the path on Windows,
+ * as ext_str is derived from filename that was already unixify */
zend_string *entry_str = phar_fix_filepath(ext_str+ext_len, computed_entry_len, false);
*entry = estrndup(ZSTR_VAL(entry_str), ZSTR_LEN(entry_str));
*entry_len = ZSTR_LEN(entry_str);
zend_string_release_ex(entry_str, false);
-#endif
} else {
*entry_len = 1;
*entry = estrndup("/", 1);