Skip to content

Commit d53ad4b

Browse files
MaxKellermannGirgias
authored andcommitted
main/SAPI: make "ini_entries" a const string
1 parent 2d662f3 commit d53ad4b

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

main/SAPI.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ struct _sapi_module_struct {
262262
void (*ini_defaults)(HashTable *configuration_hash);
263263
int phpinfo_as_text;
264264

265-
char *ini_entries;
265+
const char *ini_entries;
266266
const zend_function_entry *additional_functions;
267267
unsigned int (*input_filter_init)(void);
268268
};

sapi/embed/php_embed.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
214214
* allocated so any INI settings added via this callback will have the
215215
* lowest precedence and will allow INI files to overwrite them.
216216
*/
217-
php_embed_module.ini_entries = malloc(sizeof(HARDCODED_INI));
218-
memcpy(php_embed_module.ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI));
217+
php_embed_module.ini_entries = HARDCODED_INI;
219218

220219
/* SAPI-provided functions. */
221220
php_embed_module.additional_functions = additional_functions;
@@ -264,9 +263,4 @@ EMBED_SAPI_API void php_embed_shutdown(void)
264263
#ifdef ZTS
265264
tsrm_shutdown();
266265
#endif
267-
268-
if (php_embed_module.ini_entries) {
269-
free(php_embed_module.ini_entries);
270-
php_embed_module.ini_entries = NULL;
271-
}
272266
}

sapi/fuzzer/fuzzer-sapi.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ int fuzzer_init_php(const char *extra_ini)
144144
if (extra_ini) {
145145
ini_len += extra_ini_len + 1;
146146
}
147-
char *p = fuzzer_module.ini_entries = malloc(ini_len + 1);
147+
char *p = malloc(ini_len + 1);
148+
fuzzer_module.ini_entries = p;
148149
memcpy(p, HARDCODED_INI, sizeof(HARDCODED_INI) - 1);
149150
p += sizeof(HARDCODED_INI) - 1;
150151
if (extra_ini) {
@@ -234,7 +235,7 @@ int fuzzer_shutdown_php(void)
234235
php_module_shutdown();
235236
sapi_shutdown();
236237

237-
free(fuzzer_module.ini_entries);
238+
free((void *)fuzzer_module.ini_entries);
238239
return SUCCESS;
239240
}
240241

0 commit comments

Comments
 (0)