summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjvoisin2018-01-15 14:56:08 +0100
committerjvoisin2018-01-15 14:56:08 +0100
commit86b5068496ad86da71e2de4fcb8db0c2347a7f98 (patch)
tree365c94a1f614be9ec6ee3f483310d3fa081d1510 /src
parente96eed3a0fda3b3bcb6290a31a80ce6705826728 (diff)
Fix some memleaks
Diffstat (limited to 'src')
-rw-r--r--src/sp_cookie_encryption.c6
-rw-r--r--src/sp_unserialize.c2
-rw-r--r--src/sp_utils.c2
-rw-r--r--src/sp_var_value.c3
4 files changed, 6 insertions, 7 deletions
diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c
index 42cac85..29e96b1 100644
--- a/src/sp_cookie_encryption.c
+++ b/src/sp_cookie_encryption.c
@@ -94,7 +94,7 @@ int decrypt_cookie(zval *pDest, int num_args, va_list args,
94 94
95 generate_key(key); 95 generate_key(key);
96 96
97 decrypted = pecalloc(ZSTR_LEN(debase64), 1, 0); 97 decrypted = ecalloc(ZSTR_LEN(debase64), 1);
98 98
99 ret = crypto_secretbox_open( 99 ret = crypto_secretbox_open(
100 decrypted, 100 decrypted,
@@ -137,8 +137,8 @@ static zend_string *encrypt_data(char *data, unsigned long long data_len) {
137 137
138 unsigned char key[crypto_secretbox_KEYBYTES] = {0}; 138 unsigned char key[crypto_secretbox_KEYBYTES] = {0};
139 unsigned char nonce[crypto_secretbox_NONCEBYTES] = {0}; 139 unsigned char nonce[crypto_secretbox_NONCEBYTES] = {0};
140 unsigned char *data_to_encrypt = pecalloc(encrypted_msg_len, 1, 0); 140 unsigned char *data_to_encrypt = ecalloc(encrypted_msg_len, 1);
141 unsigned char *encrypted_data = pecalloc(emsg_and_nonce_len, 1, 1); 141 unsigned char *encrypted_data = ecalloc(emsg_and_nonce_len, 1);
142 142
143 generate_key(key); 143 generate_key(key);
144 144
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c
index f78b046..6b7b03b 100644
--- a/src/sp_unserialize.c
+++ b/src/sp_unserialize.c
@@ -57,7 +57,7 @@ PHP_FUNCTION(sp_unserialize) {
57 } 57 }
58 58
59 hmac = buf + buf_len - 64; 59 hmac = buf + buf_len - 64;
60 serialized_str = ecalloc(sizeof(*serialized_str) * (buf_len - 64 + 1), 1); 60 serialized_str = ecalloc(buf_len - 64 + 1, 1);
61 memcpy(serialized_str, buf, buf_len - 64); 61 memcpy(serialized_str, buf, buf_len - 64);
62 62
63 zval func_name; 63 zval func_name;
diff --git a/src/sp_utils.c b/src/sp_utils.c
index 52e494f..81941f7 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -360,7 +360,7 @@ int hook_function(const char* original_name, HashTable* hook_table,
360 } 360 }
361 } else { // TODO this can be moved somewhere else to gain some marginal perfs 361 } else { // TODO this can be moved somewhere else to gain some marginal perfs
362 CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN; 362 CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN;
363 char* mb_name = pecalloc(strlen(original_name) + 3 + 1, 1, 0); 363 char* mb_name = ecalloc(strlen(original_name) + 3 + 1, 1);
364 memcpy(mb_name, "mb_", 3); 364 memcpy(mb_name, "mb_", 3);
365 memcpy(mb_name + 3, VAR_AND_LEN(original_name)); 365 memcpy(mb_name + 3, VAR_AND_LEN(original_name));
366 if (zend_hash_str_find(CG(function_table), VAR_AND_LEN(mb_name))) { 366 if (zend_hash_str_find(CG(function_table), VAR_AND_LEN(mb_name))) {
diff --git a/src/sp_var_value.c b/src/sp_var_value.c
index b9d8763..a3eed3e 100644
--- a/src/sp_var_value.c
+++ b/src/sp_var_value.c
@@ -164,8 +164,7 @@ static zval *get_unknown_type(const char *restrict value, zval *zvalue,
164 } 164 }
165 if (!zvalue) { 165 if (!zvalue) {
166 zvalue = emalloc(sizeof(zval)); 166 zvalue = emalloc(sizeof(zval));
167 zvalue->value.str = zend_string_init(value, strlen(value), 0); 167 ZVAL_PSTRING(zvalue, value);
168 zvalue->u1.v.type = IS_STRING;
169 } 168 }
170 } else { 169 } else {
171 return NULL; 170 return NULL;