Skip to content

Commit 4e0ae93

Browse files
committed
ext/phar: mark _phar_archive_data.ext field as const
This char* is derived from the fname char* field.
1 parent fc9a4a3 commit 4e0ae93

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

ext/phar/phar_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ typedef struct _phar_entry_info {
245245
struct _phar_archive_data {
246246
char *fname;
247247
uint32_t fname_len;
248-
/* for phar_detect_fname_ext, this stores the location of the file extension within fname */
248+
/* The ext field stores the location of the file extension from the fname field, and thus should never be freed. */
249249
uint32_t ext_len;
250-
char *ext;
250+
const char *ext;
251251
char *alias;
252252
uint32_t alias_len;
253253
char version[12];

ext/phar/phar_object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /*
21132113
goto err_reused_oldpath;
21142114
}
21152115
if (!phar->is_data) {
2116-
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 1, 1, true)) {
2116+
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, &(phar->ext), &ext_len, 1, 1, true)) {
21172117
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", phar->fname, ext);
21182118
goto err_reused_oldpath;
21192119
}
@@ -2136,7 +2136,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /*
21362136

21372137
} else {
21382138

2139-
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 0, 1, true)) {
2139+
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, &(phar->ext), &ext_len, 0, 1, true)) {
21402140
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%s\" has invalid extension %s", phar->fname, ext);
21412141
goto err_reused_oldpath;
21422142
}

0 commit comments

Comments
 (0)