Skip to content

Commit b8c3bf9

Browse files
authored
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.
1 parent e1c5049 commit b8c3bf9

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

ext/phar/phar.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,21 +2217,12 @@ zend_result phar_split_fname(const char *filename, size_t filename_len, char **a
22172217
if (entry) {
22182218
if (ext_str[ext_len]) {
22192219
size_t computed_entry_len = filename_len - *arch_len;
2220-
#ifdef PHP_WIN32
2221-
/* TODO: can we handle the unixify path in phar_fix_filepath() directly ? */
2222-
char *fixed_path_for_windows = estrndup(ext_str+ext_len, computed_entry_len);
2223-
phar_unixify_path_separators(fixed_path_for_windows, computed_entry_len);
2224-
zend_string *entry_str = phar_fix_filepath(fixed_path_for_windows, computed_entry_len, false);
2225-
*entry = estrndup(ZSTR_VAL(entry_str), ZSTR_LEN(entry_str));
2226-
*entry_len = ZSTR_LEN(entry_str);
2227-
zend_string_release_ex(entry_str, false);
2228-
efree(fixed_path_for_windows);
2229-
#else
2220+
/* We don't need to unixify the path on Windows,
2221+
* as ext_str is derived from filename that was already unixify */
22302222
zend_string *entry_str = phar_fix_filepath(ext_str+ext_len, computed_entry_len, false);
22312223
*entry = estrndup(ZSTR_VAL(entry_str), ZSTR_LEN(entry_str));
22322224
*entry_len = ZSTR_LEN(entry_str);
22332225
zend_string_release_ex(entry_str, false);
2234-
#endif
22352226
} else {
22362227
*entry_len = 1;
22372228
*entry = estrndup("/", 1);

0 commit comments

Comments
 (0)