Skip to content

Commit c5a3f46

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

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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
@@ -2124,7 +2124,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /*
21242124
goto err_reused_oldpath;
21252125
}
21262126
if (!phar->is_data) {
2127-
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 1, 1, true)) {
2127+
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, &(phar->ext), &ext_len, 1, 1, true)) {
21282128
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", phar->fname, ext);
21292129
goto err_reused_oldpath;
21302130
}
@@ -2147,7 +2147,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /*
21472147

21482148
} else {
21492149

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

0 commit comments

Comments
 (0)