Skip to content

Commit 0da4042

Browse files
tanlisualcaeus
andauthored
PHPC-1721: Fix argument order for some ecalloc function calls (#1226)
Co-authored-by: Andreas Braun <[email protected]>
1 parent bcd1a49 commit 0da4042

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

php_phongo.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ static zval* phongo_create_implicit_session(zval* manager) /* {{{ */
933933
return NULL;
934934
}
935935

936-
zsession = ecalloc(sizeof(zval), 1);
936+
zsession = ecalloc(1, sizeof(zval));
937937

938938
phongo_session_init(zsession, manager, cs);
939939

@@ -1234,7 +1234,7 @@ zval* php_phongo_prep_legacy_option(zval* options, const char* key, bool* alloca
12341234
*allocated = false;
12351235

12361236
if (options && Z_TYPE_P(options) != IS_ARRAY) {
1237-
zval* new_options = ecalloc(sizeof(zval), 1);
1237+
zval* new_options = ecalloc(1, sizeof(zval));
12381238

12391239
array_init_size(new_options, 1);
12401240
add_assoc_zval(new_options, key, options);
@@ -2368,7 +2368,7 @@ static zval* php_phongo_manager_prepare_manager_for_hash(zval* driverOptions, bo
23682368

23692369
manager = Z_MANAGER_OBJ_P(keyVaultClient);
23702370

2371-
driverOptionsClone = ecalloc(sizeof(zval), 1);
2371+
driverOptionsClone = ecalloc(1, sizeof(zval));
23722372
autoEncryptionOptsClone = &stackAutoEncryptionOptsClone;
23732373

23742374
ZVAL_DUP(autoEncryptionOptsClone, autoEncryptionOpts);
@@ -2471,7 +2471,7 @@ static char* php_phongo_concat_handshake_data(const char* default_value, const c
24712471
ret_len += custom_value_len + PHONGO_METADATA_SEPARATOR_LEN;
24722472
}
24732473

2474-
ret = ecalloc(sizeof(char*), ret_len);
2474+
ret = ecalloc(ret_len, sizeof(char));
24752475

24762476
if (custom_value) {
24772477
snprintf(ret, ret_len, "%s%s%s ", default_value, PHONGO_METADATA_SEPARATOR, custom_value);
@@ -2491,7 +2491,7 @@ static void php_phongo_handshake_data_append(const char* name, size_t name_len,
24912491
char* full_platform;
24922492

24932493
php_version_string_len = strlen(PHP_VERSION) + PHONGO_METADATA_PHP_VERSION_PREFIX_LEN + 1;
2494-
php_version_string = ecalloc(sizeof(char*), php_version_string_len);
2494+
php_version_string = ecalloc(php_version_string_len, sizeof(char));
24952495
snprintf(php_version_string, php_version_string_len, "%s%s", PHONGO_METADATA_PHP_VERSION_PREFIX, PHP_VERSION);
24962496

24972497
driver_name = php_phongo_concat_handshake_data("ext-mongodb:PHP", name, name_len);

src/bson-encode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void php_phongo_zval_to_bson_value(zval* data, php_phongo_bson_flags_t flags, bs
503503
bson_iter_t iter;
504504
bson_t bson = BSON_INITIALIZER;
505505

506-
zval* data_object = ecalloc(sizeof(zval), 1);
506+
zval* data_object = ecalloc(1, sizeof(zval));
507507

508508
array_init_size(data_object, 1);
509509
add_assoc_zval(data_object, "data", data);

0 commit comments

Comments
 (0)