Skip to content

Commit 8b10de7

Browse files
crrodriguezMaxKellermann
authored andcommitted
Fix gcc-14 Wcalloc-transposed-args warnings
gcc-14 and later warns of inverted arguments in calloc or calloc-like __alloc_size__ annotated functions. Closes phpGH-13818.
1 parent 83e2980 commit 8b10de7

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

ext/ffi/ffi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,7 @@ static int zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry **ce_pt
20962096
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
20972097
func = &EG(trampoline);
20982098
} else {
2099-
func = ecalloc(sizeof(zend_internal_function), 1);
2099+
func = ecalloc(1, sizeof(zend_internal_function));
21002100
}
21012101
func->type = ZEND_INTERNAL_FUNCTION;
21022102
func->common.arg_flags[0] = 0;
@@ -2847,7 +2847,7 @@ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, co
28472847
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
28482848
func = &EG(trampoline);
28492849
} else {
2850-
func = ecalloc(sizeof(zend_internal_function), 1);
2850+
func = ecalloc(1, sizeof(zend_internal_function));
28512851
}
28522852
func->common.type = ZEND_INTERNAL_FUNCTION;
28532853
func->common.arg_flags[0] = 0;

ext/opcache/zend_accelerator_blacklist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist)
5858
zend_accel_blacklist_shutdown(blacklist);
5959
}
6060

61-
blacklist->entries = (zend_blacklist_entry *) calloc(sizeof(zend_blacklist_entry), blacklist->size);
61+
blacklist->entries = (zend_blacklist_entry *) calloc(blacklist->size, sizeof(zend_blacklist_entry));
6262
if (!blacklist->entries) {
6363
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Blacklist initialization: no memory\n");
6464
return;

ext/standard/proc_open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ static zend_string* get_command_from_array(HashTable *array, char ***argv, int n
713713
static descriptorspec_item* alloc_descriptor_array(HashTable *descriptorspec)
714714
{
715715
uint32_t ndescriptors = zend_hash_num_elements(descriptorspec);
716-
return ecalloc(sizeof(descriptorspec_item), ndescriptors);
716+
return ecalloc(ndescriptors, sizeof(descriptorspec_item));
717717
}
718718

719719
static zend_string* get_string_parameter(zval *array, int index, char *param_name)

main/streams/glob_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static php_stream *php_glob_stream_opener(php_stream_wrapper *wrapper, const cha
212212
return NULL;
213213
}
214214

215-
pglob = ecalloc(sizeof(*pglob), 1);
215+
pglob = ecalloc(1, sizeof(*pglob));
216216

217217
if (0 != (ret = glob(path, pglob->flags & GLOB_FLAGMASK, NULL, &pglob->glob))) {
218218
#ifdef GLOB_NOMATCH

0 commit comments

Comments
 (0)