Commit c5a3f46bb18 for php.net
commit c5a3f46bb18636ef8b36e827c800ce6989f4a054
Author: Gina Peter Banyard <girgias@php.net>
Date: Tue Apr 21 22:13:40 2026 +0100
ext/phar: mark _phar_archive_data.ext field as const
This char* is derived from the fname char* field.
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index db2856309fc..a79a1df0202 100644
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -245,9 +245,9 @@ typedef struct _phar_entry_info {
struct _phar_archive_data {
char *fname;
uint32_t fname_len;
- /* for phar_detect_fname_ext, this stores the location of the file extension within fname */
+ /* The ext field stores the location of the file extension from the fname field, and thus should never be freed. */
uint32_t ext_len;
- char *ext;
+ const char *ext;
char *alias;
uint32_t alias_len;
char version[12];
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 811a27e7931..0cde5704c2d 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -2124,7 +2124,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /*
goto err_reused_oldpath;
}
if (!phar->is_data) {
- if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 1, 1, true)) {
+ if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, &(phar->ext), &ext_len, 1, 1, true)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", phar->fname, ext);
goto err_reused_oldpath;
}
@@ -2147,7 +2147,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /*
} else {
- if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 0, 1, true)) {
+ if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, &(phar->ext), &ext_len, 0, 1, true)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%s\" has invalid extension %s", phar->fname, ext);
goto err_reused_oldpath;
}