summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_API.c18
-rw-r--r--Zend/zend_compile.c2
-rw-r--r--Zend/zend_constants.c4
-rw-r--r--Zend/zend_inheritance.c4
-rw-r--r--Zend/zend_language_scanner.c4
-rw-r--r--Zend/zend_language_scanner.l4
-rw-r--r--Zend/zend_string.h8
-rw-r--r--ext/bz2/bz2.c6
-rw-r--r--ext/date/php_date.c2
-rw-r--r--ext/iconv/iconv.c18
-rw-r--r--ext/intl/converter/converter.c2
-rw-r--r--ext/intl/idn/idn.c6
-rw-r--r--ext/intl/intl_convert.c2
-rw-r--r--ext/intl/locale/locale_methods.c2
-rw-r--r--ext/intl/uchar/uchar.c2
-rw-r--r--ext/odbc/php_odbc.c6
-rw-r--r--ext/pgsql/pgsql.c2
-rw-r--r--ext/reflection/php_reflection.c2
-rw-r--r--ext/sockets/sockets.c16
-rw-r--r--ext/sodium/libsodium.c168
-rw-r--r--ext/standard/base64.c6
-rw-r--r--ext/standard/basic_functions.c2
-rw-r--r--ext/standard/file.c2
-rw-r--r--ext/standard/html.c2
-rw-r--r--ext/standard/info.c2
-rw-r--r--ext/standard/iptc.c4
-rw-r--r--ext/standard/net.c6
-rw-r--r--ext/standard/password.c4
-rw-r--r--ext/standard/streamsfuncs.c2
-rw-r--r--ext/standard/string.c8
-rw-r--r--ext/standard/uuencode.c2
-rw-r--r--ext/standard/var_unserializer.c8
-rw-r--r--ext/standard/var_unserializer.re8
-rw-r--r--ext/zip/php_zip.c4
-rw-r--r--ext/zlib/zlib.c2
-rw-r--r--main/php_variables.c4
36 files changed, 176 insertions, 168 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 817d35a759..492a259778 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1878,13 +1878,13 @@ ZEND_API int zend_startup_module_ex(zend_module_entry *module) /* {{{ */
zend_str_tolower_copy(ZSTR_VAL(lcname), dep->name, name_len);
if ((req_mod = zend_hash_find_ptr(&module_registry, lcname)) == NULL || !req_mod->module_started) {
- zend_string_free(lcname);
+ zend_string_efree(lcname);
/* TODO: Check version relationship */
zend_error(E_CORE_WARNING, "Cannot load module '%s' because required module '%s' is not loaded", module->name, dep->name);
module->module_started = 0;
return FAILURE;
}
- zend_string_free(lcname);
+ zend_string_efree(lcname);
}
++dep;
}
@@ -2066,12 +2066,12 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module) /
zend_str_tolower_copy(ZSTR_VAL(lcname), dep->name, name_len);
if (zend_hash_exists(&module_registry, lcname) || zend_get_extension(dep->name)) {
- zend_string_free(lcname);
+ zend_string_efree(lcname);
/* TODO: Check version relationship */
zend_error(E_CORE_WARNING, "Cannot load module '%s' because conflicting module '%s' is already loaded", module->name, dep->name);
return NULL;
}
- zend_string_free(lcname);
+ zend_string_efree(lcname);
}
++dep;
}
@@ -2411,7 +2411,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
if (zend_hash_exists(target_function_table, lowercase_name)) {
zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
}
- zend_string_free(lowercase_name);
+ zend_string_efree(lowercase_name);
ptr++;
}
zend_unregister_functions(functions, count, target_function_table);
@@ -2536,7 +2536,7 @@ ZEND_API void zend_unregister_functions(const zend_function_entry *functions, in
lowercase_name = zend_string_alloc(fname_len, 0);
zend_str_tolower_copy(ZSTR_VAL(lowercase_name), ptr->fname, fname_len);
zend_hash_del(target_function_table, lowercase_name);
- zend_string_free(lowercase_name);
+ zend_string_efree(lowercase_name);
ptr++;
i++;
}
@@ -3698,7 +3698,7 @@ ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
lname = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(ZSTR_VAL(lname), module_name, name_len);
module = zend_hash_find_ptr(&module_registry, lname);
- zend_string_free(lname);
+ zend_string_efree(lname);
return module ? module->version : NULL;
}
/* }}} */
@@ -4096,7 +4096,7 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *na
EG(fake_scope) = scope;
property = zend_std_get_static_property(scope, key, 0);
EG(fake_scope) = old_scope;
- zend_string_free(key);
+ zend_string_efree(key);
if (!property) {
return FAILURE;
} else {
@@ -4222,7 +4222,7 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *na
EG(fake_scope) = scope;
property = zend_std_get_static_property(scope, key, silent);
EG(fake_scope) = old_scope;
- zend_string_free(key);
+ zend_string_efree(key);
return property;
}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 448856dd92..08c530d363 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -6588,7 +6588,7 @@ void zend_compile_use(zend_ast *ast) /* {{{ */
zend_check_already_in_use(type, old_name, new_name, ns_name);
}
- zend_string_free(ns_name);
+ zend_string_efree(ns_name);
} else {
if (zend_have_seen_symbol(lookup_name, type)) {
zend_check_already_in_use(type, old_name, new_name, lookup_name);
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index a2e25c89df..b07901c470 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -226,7 +226,7 @@ static zend_constant *zend_get_special_constant(const char *name, size_t name_le
haltname = zend_mangle_property_name(haltoff,
sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0);
c = zend_hash_find_ptr(EG(zend_constants), haltname);
- zend_string_free(haltname);
+ zend_string_efree(haltname);
return c;
} else {
return NULL;
@@ -379,7 +379,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
}
failure:
zend_string_release(class_name);
- zend_string_free(constant_name);
+ zend_string_efree(constant_name);
return ret_constant;
}
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 46a674ba90..8af706a1d0 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -619,8 +619,8 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
error_verb = "should";
}
zend_error(error_level, "Declaration of %s %s be compatible with %s", ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype));
- zend_string_free(child_prototype);
- zend_string_free(method_prototype);
+ zend_string_efree(child_prototype);
+ zend_string_efree(method_prototype);
}
}
/* }}} */
diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c
index 42e209ab91..f9a316ac23 100644
--- a/Zend/zend_language_scanner.c
+++ b/Zend/zend_language_scanner.c
@@ -2034,11 +2034,11 @@ heredoc_scan_done:
}
if (UNEXPECTED(zend_scan_escape_string(zendlval, ZSTR_VAL(copy), ZSTR_LEN(copy), 0) != SUCCESS)) {
- zend_string_free(copy);
+ zend_string_efree(copy);
RETURN_TOKEN(T_ERROR);
}
- zend_string_free(copy);
+ zend_string_efree(copy);
} else {
HANDLE_NEWLINES(yytext, yyleng - newline);
}
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 15afc43887..fb4b7386e5 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -2620,11 +2620,11 @@ heredoc_scan_done:
}
if (UNEXPECTED(zend_scan_escape_string(zendlval, ZSTR_VAL(copy), ZSTR_LEN(copy), 0) != SUCCESS)) {
- zend_string_free(copy);
+ zend_string_efree(copy);
RETURN_TOKEN(T_ERROR);
}
- zend_string_free(copy);
+ zend_string_efree(copy);
} else {
HANDLE_NEWLINES(yytext, yyleng - newline);
}
diff --git a/Zend/zend_string.h b/Zend/zend_string.h
index fe2a7475c4..d517b74020 100644
--- a/Zend/zend_string.h
+++ b/Zend/zend_string.h
@@ -264,6 +264,14 @@ static zend_always_inline void zend_string_free(zend_string *s)
}
}
+static zend_always_inline void zend_string_efree(zend_string *s)
+{
+ ZEND_ASSERT(!ZSTR_IS_INTERNED(s));
+ ZEND_ASSERT(GC_REFCOUNT(s) <= 1);
+ ZEND_ASSERT(!(GC_FLAGS(s) & IS_STR_PERSISTENT));
+ efree(s);
+}
+
static zend_always_inline void zend_string_release(zend_string *s)
{
if (!ZSTR_IS_INTERNED(s)) {
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c
index 502c9a7062..2d6ffc28ea 100644
--- a/ext/bz2/bz2.c
+++ b/ext/bz2/bz2.c
@@ -546,7 +546,7 @@ static PHP_FUNCTION(bzcompress)
error = BZ2_bzBuffToBuffCompress(ZSTR_VAL(dest), &dest_len, source, source_len, block_size, 0, work_factor);
if (error != BZ_OK) {
- zend_string_free(dest);
+ zend_string_efree(dest);
RETURN_LONG(error);
} else {
/* Copy the buffer, we have perhaps allocate a lot more than we need,
@@ -612,7 +612,7 @@ static PHP_FUNCTION(bzdecompress)
#if !ZEND_ENABLE_ZVAL_LONG64
if (UNEXPECTED(size > SIZE_MAX)) {
php_error_docref(NULL, E_WARNING, "Decompressed size too big, max is %zd", SIZE_MAX);
- zend_string_free(dest);
+ zend_string_efree(dest);
RETVAL_LONG(BZ_MEM_ERROR);
} else
#endif
@@ -623,7 +623,7 @@ static PHP_FUNCTION(bzdecompress)
RETVAL_STR(dest);
}
} else { /* real error */
- zend_string_free(dest);
+ zend_string_efree(dest);
RETVAL_LONG(error);
}
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index ed92dd5f0d..be1df2d81c 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1738,7 +1738,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
buf = zend_string_truncate(buf, real_len, 0);
RETURN_NEW_STR(buf);
}
- zend_string_free(buf);
+ zend_string_efree(buf);
RETURN_FALSE;
}
/* }}} */
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 4ebce2c156..34641d882c 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -438,7 +438,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
if (out) {
output_context->out.data = estrndup(ZSTR_VAL(out), ZSTR_LEN(out));
output_context->out.used = ZSTR_LEN(out);
- zend_string_free(out);
+ zend_string_efree(out);
} else {
output_context->out.data = NULL;
output_context->out.used = 0;
@@ -585,7 +585,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
result = iconv(cd, (const char **) &in_p, &in_size, (char **) &out_p, &out_left);
if (result == (size_t)(-1)) {
- zend_string_free(out_buffer);
+ zend_string_efree(out_buffer);
return PHP_ICONV_ERR_UNKNOWN;
}
@@ -601,7 +601,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
result = iconv(cd, NULL, NULL, &out_p, &out_left);
if (result == (size_t)(-1)) {
- zend_string_free(out_buffer);
+ zend_string_efree(out_buffer);
return PHP_ICONV_ERR_UNKNOWN;
}
@@ -713,7 +713,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
default:
/* other error */
- zend_string_free(out_buf);
+ zend_string_efree(out_buf);
return PHP_ICONV_ERR_UNKNOWN;
}
}
@@ -987,7 +987,7 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
if (err != PHP_ICONV_ERR_SUCCESS) {
if (ndl_buf != NULL) {
- zend_string_free(ndl_buf);
+ zend_string_efree(ndl_buf);
}
return err;
}
@@ -996,7 +996,7 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
if (cd == (iconv_t)(-1)) {
if (ndl_buf != NULL) {
- zend_string_free(ndl_buf);
+ zend_string_efree(ndl_buf);
}
#if ICONV_SUPPORTS_ERRNO
if (errno == EINVAL) {
@@ -1131,7 +1131,7 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
}
if (ndl_buf) {
- zend_string_free(ndl_buf);
+ zend_string_efree(ndl_buf);
}
iconv_close(cd);
@@ -2463,10 +2463,10 @@ PHP_NAMED_FUNCTION(php_if_iconv)
err = php_iconv_string(ZSTR_VAL(in_buffer), (size_t)ZSTR_LEN(in_buffer), &out_buffer, out_charset, in_charset);
_php_iconv_show_error(err, out_charset, in_charset);
if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
- RETVAL_STR(out_buffer);
+ RETVAL_NEW_STR(out_buffer);
} else {
if (out_buffer != NULL) {
- zend_string_free(out_buffer);
+ zend_string_efree(out_buffer);
}
RETURN_FALSE;
}
diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c
index f54006fe69..e26173b10a 100644
--- a/ext/intl/converter/converter.c
+++ b/ext/intl/converter/converter.c
@@ -705,7 +705,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv,
efree(temp);
if (U_FAILURE(error)) {
THROW_UFAILURE(objval, "ucnv_fromUChars", error);
- zend_string_free(ret);
+ zend_string_efree(ret);
return NULL;
}
diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c
index a7f40ba66e..02e341fa38 100644
--- a/ext/intl/idn/idn.c
+++ b/ext/intl/idn/idn.c
@@ -146,7 +146,7 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
uts46 = uidna_openUTS46(option, &status);
if (php_intl_idn_check_status(status, "failed to open UIDNA instance") == FAILURE) {
- zend_string_free(buffer);
+ zend_string_efree(buffer);
RETURN_FALSE;
}
@@ -159,7 +159,7 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
}
if (len >= 255 || php_intl_idn_check_status(status, "failed to convert name") == FAILURE) {
uidna_close(uts46);
- zend_string_free(buffer);
+ zend_string_efree(buffer);
RETURN_FALSE;
}
@@ -189,7 +189,7 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
}
if (!buffer_used) {
- zend_string_free(buffer);
+ zend_string_efree(buffer);
}
uidna_close(uts46);
diff --git a/ext/intl/intl_convert.c b/ext/intl/intl_convert.c
index 2ae43fbb96..eadcf2c9f1 100644
--- a/ext/intl/intl_convert.c
+++ b/ext/intl/intl_convert.c
@@ -141,7 +141,7 @@ zend_string* intl_convert_utf16_to_utf8(
u_strToUTF8( ZSTR_VAL(dst), dst_len, NULL, src, src_len, status );
if( U_FAILURE( *status ) )
{
- zend_string_free(dst);
+ zend_string_efree(dst);
return NULL;
}
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
index d12df97a38..f300fa88ff 100644
--- a/ext/intl/locale/locale_methods.c
+++ b/ext/intl/locale/locale_methods.c
@@ -742,7 +742,7 @@ PHP_FUNCTION( locale_get_keywords )
if (U_FAILURE(status)) {
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_get_keywords: Error encountered while getting the keyword value for the keyword", 0 );
if( kw_value_str){
- zend_string_free( kw_value_str );
+ zend_string_efree( kw_value_str );
}
zval_dtor(return_value);
RETURN_FALSE;
diff --git a/ext/intl/uchar/uchar.c b/ext/intl/uchar/uchar.c
index 2cec0a4b8a..c3fe66f823 100644
--- a/ext/intl/uchar/uchar.c
+++ b/ext/intl/uchar/uchar.c
@@ -261,7 +261,7 @@ IC_METHOD(charName) {
error = U_ZERO_ERROR;
buffer_len = u_charName(cp, (UCharNameChoice)nameChoice, ZSTR_VAL(buffer), ZSTR_LEN(buffer) + 1, &error);
if (U_FAILURE(error)) {
- zend_string_free(buffer);
+ zend_string_efree(buffer);
INTL_CHECK_STATUS_OR_NULL(error, "Failure getting character name");
}
RETURN_NEW_STR(buffer);
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 8675665444..fefb6d91b2 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -2193,15 +2193,15 @@ PHP_FUNCTION(odbc_result)
if (rc == SQL_ERROR) {
odbc_sql_error(result->conn_ptr, result->stmt, "SQLGetData");
- zend_string_free(field_str);
+ zend_string_efree(field_str);
RETURN_FALSE;
}
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
- zend_string_free(field_str);
+ zend_string_efree(field_str);
RETURN_NULL();
} else if (rc == SQL_NO_DATA_FOUND) {
- zend_string_free(field_str);
+ zend_string_efree(field_str);
RETURN_FALSE;
}
/* Reduce fieldlen by 1 if we have char data. One day we might
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 81a1bdbb3c..f0873ce854 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -3531,7 +3531,7 @@ PHP_FUNCTION(pg_lo_read)
buf = zend_string_alloc(buf_len, 0);
if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, ZSTR_VAL(buf), ZSTR_LEN(buf)))<0) {
- zend_string_free(buf);
+ zend_string_efree(buf);
RETURN_FALSE;
}
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 391183addf..87ffeba666 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1130,7 +1130,7 @@ static void reflection_extension_factory(zval *object, const char *name_str)
lcname = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(ZSTR_VAL(lcname), name_str, name_len);
module = zend_hash_find_ptr(&module_registry, lcname);
- zend_string_free(lcname);
+ zend_string_efree(lcname);
if (!module) {
return;
}
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index e8834479dc..104eaf339e 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -1232,10 +1232,10 @@ PHP_FUNCTION(socket_read)
PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
}
- zend_string_free(tmpbuf);
+ zend_string_efree(tmpbuf);
RETURN_FALSE;
} else if (!retval) {
- zend_string_free(tmpbuf);
+ zend_string_efree(tmpbuf);
RETURN_EMPTY_STRING();
}
@@ -1670,7 +1670,7 @@ PHP_FUNCTION(socket_recv)
recv_buf = zend_string_alloc(len, 0);
if ((retval = recv(php_sock->bsd_socket, ZSTR_VAL(recv_buf), len, flags)) < 1) {
- zend_string_free(recv_buf);
+ zend_string_efree(recv_buf);
zval_ptr_dtor(buf);
ZVAL_NULL(buf);
@@ -1762,7 +1762,7 @@ PHP_FUNCTION(socket_recvfrom)
if (retval < 0) {
PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
- zend_string_free(recv_buf);
+ zend_string_efree(recv_buf);
RETURN_FALSE;
}
ZSTR_LEN(recv_buf) = retval;
@@ -1781,7 +1781,7 @@ PHP_FUNCTION(socket_recvfrom)
sin.sin_family = AF_INET;
if (arg6 == NULL) {
- zend_string_free(recv_buf);
+ zend_string_efree(recv_buf);
WRONG_PARAM_COUNT;
}
@@ -1789,7 +1789,7 @@ PHP_FUNCTION(socket_recvfrom)
if (retval < 0) {
PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
- zend_string_free(recv_buf);
+ zend_string_efree(recv_buf);
RETURN_FALSE;
}
ZSTR_LEN(recv_buf) = retval;
@@ -1812,7 +1812,7 @@ PHP_FUNCTION(socket_recvfrom)
sin6.sin6_family = AF_INET6;
if (arg6 == NULL) {
- zend_string_free(recv_buf);
+ zend_string_efree(recv_buf);
WRONG_PARAM_COUNT;
}
@@ -1820,7 +1820,7 @@ PHP_FUNCTION(socket_recvfrom)
if (retval < 0) {
PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
- zend_string_free(recv_buf);
+ zend_string_efree(recv_buf);
RETURN_FALSE;
}
ZSTR_LEN(recv_buf) = retval;
diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c
index d7af877b1f..5791bc5114 100644
--- a/ext/sodium/libsodium.c
+++ b/ext/sodium/libsodium.c
@@ -768,13 +768,13 @@ PHP_FUNCTION(sodium_crypto_shorthash)
hash = zend_string_alloc(crypto_shorthash_BYTES, 0);
if (crypto_shorthash((unsigned char *) ZSTR_VAL(hash), msg,
(unsigned long long) msg_len, key) != 0) {
- zend_string_free(hash);
+ zend_string_efree(hash);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(hash)[crypto_shorthash_BYTES] = 0;
- RETURN_STR(hash);
+ RETURN_NEW_STR(hash);
}
PHP_FUNCTION(sodium_crypto_secretbox)
@@ -814,13 +814,13 @@ PHP_FUNCTION(sodium_crypto_secretbox)
if (crypto_secretbox_easy((unsigned char *) ZSTR_VAL(ciphertext),
msg, (unsigned long long) msg_len,
nonce, key) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(ciphertext)[msg_len + crypto_secretbox_MACBYTES] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_secretbox_open)
@@ -860,11 +860,11 @@ PHP_FUNCTION(sodium_crypto_secretbox_open)
if (crypto_secretbox_open_easy((unsigned char *) ZSTR_VAL(msg), ciphertext,
(unsigned long long) ciphertext_len,
nonce, key) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
} else {
ZSTR_VAL(msg)[ciphertext_len - crypto_secretbox_MACBYTES] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
}
@@ -899,13 +899,13 @@ PHP_FUNCTION(sodium_crypto_generichash)
if (crypto_generichash((unsigned char *) ZSTR_VAL(hash), (size_t) hash_len,
msg, (unsigned long long) msg_len,
key, (size_t) key_len) != 0) {
- zend_string_free(hash);
+ zend_string_efree(hash);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(hash)[hash_len] = 0;
- RETURN_STR(hash);
+ RETURN_NEW_STR(hash);
}
PHP_FUNCTION(sodium_crypto_generichash_init)
@@ -1023,7 +1023,7 @@ PHP_FUNCTION(sodium_crypto_generichash_final)
(unsigned char *) ZSTR_VAL(hash),
(size_t) hash_len) != 0) {
sodium_memzero(&state_tmp, sizeof state_tmp);
- zend_string_free(hash);
+ zend_string_efree(hash);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
@@ -1032,7 +1032,7 @@ PHP_FUNCTION(sodium_crypto_generichash_final)
convert_to_null(state_zv);
ZSTR_VAL(hash)[hash_len] = 0;
- RETURN_STR(hash);
+ RETURN_NEW_STR(hash);
}
PHP_FUNCTION(sodium_crypto_box_keypair)
@@ -1048,13 +1048,13 @@ PHP_FUNCTION(sodium_crypto_box_keypair)
if (crypto_box_keypair((unsigned char *) ZSTR_VAL(keypair) +
crypto_box_SECRETKEYBYTES,
(unsigned char *) ZSTR_VAL(keypair)) != 0) {
- zend_string_free(keypair);
+ zend_string_efree(keypair);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(keypair)[keypair_len] = 0;
- RETURN_STR(keypair);
+ RETURN_NEW_STR(keypair);
}
PHP_FUNCTION(sodium_crypto_box_seed_keypair)
@@ -1081,13 +1081,13 @@ PHP_FUNCTION(sodium_crypto_box_seed_keypair)
crypto_box_SECRETKEYBYTES,
(unsigned char *) ZSTR_VAL(keypair),
seed) != 0) {
- zend_string_free(keypair);
+ zend_string_efree(keypair);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(keypair)[keypair_len] = 0;
- RETURN_STR(keypair);
+ RETURN_NEW_STR(keypair);
}
PHP_FUNCTION(sodium_crypto_box_keypair_from_secretkey_and_publickey)
@@ -1247,13 +1247,13 @@ PHP_FUNCTION(sodium_crypto_box)
if (crypto_box_easy((unsigned char *) ZSTR_VAL(ciphertext), msg,
(unsigned long long) msg_len,
nonce, publickey, secretkey) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(ciphertext)[msg_len + crypto_box_MACBYTES] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_box_open)
@@ -1296,11 +1296,11 @@ PHP_FUNCTION(sodium_crypto_box_open)
if (crypto_box_open_easy((unsigned char *) ZSTR_VAL(msg), ciphertext,
(unsigned long long) ciphertext_len,
nonce, publickey, secretkey) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
} else {
ZSTR_VAL(msg)[ciphertext_len - crypto_box_MACBYTES] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
}
@@ -1331,13 +1331,13 @@ PHP_FUNCTION(sodium_crypto_box_seal)
ciphertext = zend_string_alloc((size_t) msg_len + crypto_box_SEALBYTES, 0);
if (crypto_box_seal((unsigned char *) ZSTR_VAL(ciphertext), msg,
(unsigned long long) msg_len, publickey) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(ciphertext)[msg_len + crypto_box_SEALBYTES] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_box_seal_open)
@@ -1371,11 +1371,11 @@ PHP_FUNCTION(sodium_crypto_box_seal_open)
if (crypto_box_seal_open((unsigned char *) ZSTR_VAL(msg), ciphertext,
(unsigned long long) ciphertext_len,
publickey, secretkey) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
} else {
ZSTR_VAL(msg)[ciphertext_len - crypto_box_SEALBYTES] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
}
@@ -1392,13 +1392,13 @@ PHP_FUNCTION(sodium_crypto_sign_keypair)
if (crypto_sign_keypair((unsigned char *) ZSTR_VAL(keypair) +
crypto_sign_SECRETKEYBYTES,
(unsigned char *) ZSTR_VAL(keypair)) != 0) {
- zend_string_free(keypair);
+ zend_string_efree(keypair);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(keypair)[keypair_len] = 0;
- RETURN_STR(keypair);
+ RETURN_NEW_STR(keypair);
}
PHP_FUNCTION(sodium_crypto_sign_seed_keypair)
@@ -1425,13 +1425,13 @@ PHP_FUNCTION(sodium_crypto_sign_seed_keypair)
crypto_sign_SECRETKEYBYTES,
(unsigned char *) ZSTR_VAL(keypair),
seed) != 0) {
- zend_string_free(keypair);
+ zend_string_efree(keypair);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(keypair)[keypair_len] = 0;
- RETURN_STR(keypair);
+ RETURN_NEW_STR(keypair);
}
PHP_FUNCTION(sodium_crypto_sign_keypair_from_secretkey_and_publickey)
@@ -1583,19 +1583,19 @@ PHP_FUNCTION(sodium_crypto_sign)
if (crypto_sign((unsigned char *) ZSTR_VAL(msg_signed),
&msg_signed_real_len, msg,
(unsigned long long) msg_len, secretkey) != 0) {
- zend_string_free(msg_signed);
+ zend_string_efree(msg_signed);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
if (msg_signed_real_len >= SIZE_MAX || msg_signed_real_len > msg_signed_len) {
- zend_string_free(msg_signed);
+ zend_string_efree(msg_signed);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(msg_signed, (size_t) msg_signed_real_len);
ZSTR_VAL(msg_signed)[msg_signed_real_len] = 0;
- RETURN_STR(msg_signed);
+ RETURN_NEW_STR(msg_signed);
}
PHP_FUNCTION(sodium_crypto_sign_open)
@@ -1629,18 +1629,18 @@ PHP_FUNCTION(sodium_crypto_sign_open)
if (crypto_sign_open((unsigned char *) ZSTR_VAL(msg), &msg_real_len,
msg_signed, (unsigned long long) msg_signed_len,
publickey) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
}
if (msg_real_len >= SIZE_MAX || msg_real_len > msg_signed_len) {
- zend_string_free(msg);
+ zend_string_efree(msg);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(msg, (size_t) msg_real_len);
ZSTR_VAL(msg)[msg_real_len] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
PHP_FUNCTION(sodium_crypto_sign_detached)
@@ -1669,18 +1669,18 @@ PHP_FUNCTION(sodium_crypto_sign_detached)
if (crypto_sign_detached((unsigned char *) ZSTR_VAL(signature),
&signature_real_len, msg,
(unsigned long long) msg_len, secretkey) != 0) {
- zend_string_free(signature);
+ zend_string_efree(signature);
zend_throw_exception(sodium_exception_ce, "signature creation failed", 0);
return;
}
if (signature_real_len <= 0U || signature_real_len > crypto_sign_BYTES) {
- zend_string_free(signature);
+ zend_string_efree(signature);
zend_throw_exception(sodium_exception_ce, "signature has a bogus size", 0);
return;
}
ZEND_ASSERT(ZSTR_VAL(signature)[signature_real_len] == 0);
- RETURN_STR(signature);
+ RETURN_NEW_STR(signature);
}
PHP_FUNCTION(sodium_crypto_sign_verify_detached)
@@ -1750,13 +1750,13 @@ PHP_FUNCTION(sodium_crypto_stream)
ciphertext = zend_string_alloc((size_t) ciphertext_len, 0);
if (crypto_stream((unsigned char *) ZSTR_VAL(ciphertext),
(unsigned long long) ciphertext_len, nonce, key) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(ciphertext)[ciphertext_len] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_stream_xor)
@@ -1789,13 +1789,13 @@ PHP_FUNCTION(sodium_crypto_stream_xor)
ciphertext = zend_string_alloc((size_t) ciphertext_len, 0);
if (crypto_stream_xor((unsigned char *) ZSTR_VAL(ciphertext), msg,
(unsigned long long) msg_len, nonce, key) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(ciphertext)[ciphertext_len] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
#ifdef crypto_pwhash_SALTBYTES
@@ -1878,13 +1878,13 @@ PHP_FUNCTION(sodium_crypto_pwhash)
(unsigned long long) opslimit, (size_t) memlimit, (int) alg);
}
if (ret != 0) {
- zend_string_free(hash);
+ zend_string_efree(hash);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(hash)[hash_len] = 0;
- RETURN_STR(hash);
+ RETURN_NEW_STR(hash);
}
PHP_FUNCTION(sodium_crypto_pwhash_str)
@@ -1929,7 +1929,7 @@ PHP_FUNCTION(sodium_crypto_pwhash_str)
if (crypto_pwhash_str
(ZSTR_VAL(hash_str), passwd, (unsigned long long) passwd_len,
(unsigned long long) opslimit, (size_t) memlimit) != 0) {
- zend_string_free(hash_str);
+ zend_string_efree(hash_str);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
@@ -1938,7 +1938,7 @@ PHP_FUNCTION(sodium_crypto_pwhash_str)
len = strlen(ZSTR_VAL(hash_str));
PHP_SODIUM_ZSTR_TRUNCATE(hash_str, len);
- RETURN_STR(hash_str);
+ RETURN_NEW_STR(hash_str);
}
#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6)
@@ -2044,13 +2044,13 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256)
((unsigned char *) ZSTR_VAL(hash), (unsigned long long) hash_len,
passwd, (unsigned long long) passwd_len, salt,
(unsigned long long) opslimit, (size_t) memlimit) != 0) {
- zend_string_free(hash);
+ zend_string_efree(hash);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(hash)[hash_len] = 0;
- RETURN_STR(hash);
+ RETURN_NEW_STR(hash);
}
PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str)
@@ -2091,13 +2091,13 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str)
if (crypto_pwhash_scryptsalsa208sha256_str
(ZSTR_VAL(hash_str), passwd, (unsigned long long) passwd_len,
(unsigned long long) opslimit, (size_t) memlimit) != 0) {
- zend_string_free(hash_str);
+ zend_string_efree(hash_str);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(hash_str)[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1] = 0;
- RETURN_STR(hash_str);
+ RETURN_NEW_STR(hash_str);
}
PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str_verify)
@@ -2191,20 +2191,20 @@ PHP_FUNCTION(sodium_crypto_aead_aes256gcm_encrypt)
((unsigned char *) ZSTR_VAL(ciphertext), &ciphertext_real_len, msg,
(unsigned long long) msg_len,
ad, (unsigned long long) ad_len, NULL, npub, secretkey) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
if (ciphertext_real_len <= 0U || ciphertext_real_len >= SIZE_MAX ||
ciphertext_real_len > ciphertext_len) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(ciphertext, (size_t) ciphertext_real_len);
ZSTR_VAL(ciphertext)[ciphertext_real_len] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_aead_aes256gcm_decrypt)
@@ -2260,18 +2260,18 @@ PHP_FUNCTION(sodium_crypto_aead_aes256gcm_decrypt)
((unsigned char *) ZSTR_VAL(msg), &msg_real_len, NULL,
ciphertext, (unsigned long long) ciphertext_len,
ad, (unsigned long long) ad_len, npub, secretkey) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
}
if (msg_real_len >= SIZE_MAX || msg_real_len > msg_len) {
- zend_string_free(msg);
+ zend_string_efree(msg);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(msg, (size_t) msg_real_len);
ZSTR_VAL(msg)[msg_real_len] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
#endif
@@ -2321,20 +2321,20 @@ PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_encrypt)
((unsigned char *) ZSTR_VAL(ciphertext), &ciphertext_real_len, msg,
(unsigned long long) msg_len,
ad, (unsigned long long) ad_len, NULL, npub, secretkey) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
if (ciphertext_real_len <= 0U || ciphertext_real_len >= SIZE_MAX ||
ciphertext_real_len > ciphertext_len) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(ciphertext, (size_t) ciphertext_real_len);
ZSTR_VAL(ciphertext)[ciphertext_real_len] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_decrypt)
@@ -2386,18 +2386,18 @@ PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_decrypt)
((unsigned char *) ZSTR_VAL(msg), &msg_real_len, NULL,
ciphertext, (unsigned long long) ciphertext_len,
ad, (unsigned long long) ad_len, npub, secretkey) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
}
if (msg_real_len >= SIZE_MAX || msg_real_len > msg_len) {
- zend_string_free(msg);
+ zend_string_efree(msg);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(msg, (size_t) msg_real_len);
ZSTR_VAL(msg)[msg_real_len] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_ietf_encrypt)
@@ -2450,20 +2450,20 @@ PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_ietf_encrypt)
((unsigned char *) ZSTR_VAL(ciphertext), &ciphertext_real_len, msg,
(unsigned long long) msg_len,
ad, (unsigned long long) ad_len, NULL, npub, secretkey) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
if (ciphertext_real_len <= 0U || ciphertext_real_len >= SIZE_MAX ||
ciphertext_real_len > ciphertext_len) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(ciphertext, (size_t) ciphertext_real_len);
ZSTR_VAL(ciphertext)[ciphertext_real_len] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_ietf_decrypt)
@@ -2520,18 +2520,18 @@ PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_ietf_decrypt)
((unsigned char *) ZSTR_VAL(msg), &msg_real_len, NULL,
ciphertext, (unsigned long long) ciphertext_len,
ad, (unsigned long long) ad_len, npub, secretkey) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
}
if (msg_real_len >= SIZE_MAX || msg_real_len > msg_len) {
- zend_string_free(msg);
+ zend_string_efree(msg);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(msg, (size_t) msg_real_len);
ZSTR_VAL(msg)[msg_real_len] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
#ifdef crypto_aead_xchacha20poly1305_IETF_NPUBBYTES
@@ -2581,20 +2581,20 @@ PHP_FUNCTION(sodium_crypto_aead_xchacha20poly1305_ietf_encrypt)
((unsigned char *) ZSTR_VAL(ciphertext), &ciphertext_real_len, msg,
(unsigned long long) msg_len,
ad, (unsigned long long) ad_len, NULL, npub, secretkey) != 0) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
if (ciphertext_real_len <= 0U || ciphertext_real_len >= SIZE_MAX ||
ciphertext_real_len > ciphertext_len) {
- zend_string_free(ciphertext);
+ zend_string_efree(ciphertext);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(ciphertext, (size_t) ciphertext_real_len);
ZSTR_VAL(ciphertext)[ciphertext_real_len] = 0;
- RETURN_STR(ciphertext);
+ RETURN_NEW_STR(ciphertext);
}
PHP_FUNCTION(sodium_crypto_aead_xchacha20poly1305_ietf_decrypt)
@@ -2651,18 +2651,18 @@ PHP_FUNCTION(sodium_crypto_aead_xchacha20poly1305_ietf_decrypt)
((unsigned char *) ZSTR_VAL(msg), &msg_real_len, NULL,
ciphertext, (unsigned long long) ciphertext_len,
ad, (unsigned long long) ad_len, npub, secretkey) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
}
if (msg_real_len >= SIZE_MAX || msg_real_len > msg_len) {
- zend_string_free(msg);
+ zend_string_efree(msg);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(msg, (size_t) msg_real_len);
ZSTR_VAL(msg)[msg_real_len] = 0;
- RETURN_STR(msg);
+ RETURN_NEW_STR(msg);
}
#endif
@@ -2712,19 +2712,19 @@ PHP_FUNCTION(sodium_hex2bin)
if (sodium_hex2bin((unsigned char *) ZSTR_VAL(bin), bin_len, hex, hex_len,
ignore, &bin_real_len, &end) != 0 ||
end != hex + hex_len) {
- zend_string_free(bin);
+ zend_string_efree(bin);
zend_throw_exception(sodium_exception_ce, "invalid hex string", 0);
return;
}
if (bin_real_len >= SIZE_MAX || bin_real_len > bin_len) {
- zend_string_free(bin);
+ zend_string_efree(bin);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(bin, (size_t) bin_real_len);
ZSTR_VAL(bin)[bin_real_len] = 0;
- RETURN_STR(bin);
+ RETURN_NEW_STR(bin);
}
#ifdef sodium_base64_VARIANT_ORIGINAL
@@ -2786,19 +2786,19 @@ PHP_FUNCTION(sodium_base642bin)
b64, b64_len,
ignore, &bin_real_len, &end, (int) variant) != 0 ||
end != b64 + b64_len) {
- zend_string_free(bin);
+ zend_string_efree(bin);
zend_throw_exception(sodium_exception_ce, "invalid base64 string", 0);
return;
}
if (bin_real_len >= SIZE_MAX || bin_real_len > bin_len) {
- zend_string_free(bin);
+ zend_string_efree(bin);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(bin, (size_t) bin_real_len);
ZSTR_VAL(bin)[bin_real_len] = 0;
- RETURN_STR(bin);
+ RETURN_NEW_STR(bin);
}
#endif
@@ -2824,13 +2824,13 @@ PHP_FUNCTION(sodium_crypto_scalarmult)
}
q = zend_string_alloc(crypto_scalarmult_BYTES, 0);
if (crypto_scalarmult((unsigned char *) ZSTR_VAL(q), n, p) != 0) {
- zend_string_free(q);
+ zend_string_efree(q);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(q)[crypto_scalarmult_BYTES] = 0;
- RETURN_STR(q);
+ RETURN_NEW_STR(q);
}
PHP_FUNCTION(sodium_crypto_kx_seed_keypair)
@@ -3585,19 +3585,19 @@ PHP_FUNCTION(sodium_crypto_secretstream_xchacha20poly1305_push)
((void *) state, (unsigned char *) ZSTR_VAL(c), &c_real_len,
msg, (unsigned long long) msg_len, ad, (unsigned long long) ad_len,
(unsigned char) tag) != 0) {
- zend_string_free(c);
+ zend_string_efree(c);
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
if (c_real_len <= 0U || c_real_len >= SIZE_MAX || c_real_len > c_len) {
- zend_string_free(c);
+ zend_string_efree(c);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
PHP_SODIUM_ZSTR_TRUNCATE(c, (size_t) c_real_len);
ZSTR_VAL(c)[c_real_len] = 0;
- RETURN_STR(c);
+ RETURN_NEW_STR(c);
}
PHP_FUNCTION(sodium_crypto_secretstream_xchacha20poly1305_init_pull)
@@ -3674,11 +3674,11 @@ PHP_FUNCTION(sodium_crypto_secretstream_xchacha20poly1305_pull)
if (crypto_secretstream_xchacha20poly1305_pull
((void *) state, (unsigned char *) ZSTR_VAL(msg), &msg_real_len, &tag,
c, (unsigned long long) c_len, ad, (unsigned long long) ad_len) != 0) {
- zend_string_free(msg);
+ zend_string_efree(msg);
RETURN_FALSE;
}
if (msg_real_len >= SIZE_MAX || msg_real_len > msg_len) {
- zend_string_free(msg);
+ zend_string_efree(msg);
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
return;
}
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index c3fb869e8e..54da85c0b7 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -699,7 +699,7 @@ zend_string *php_base64_decode_ex_ssse3(const unsigned char *str, size_t length,
# endif
if (!php_base64_decode_impl(c, length, (unsigned char*)ZSTR_VAL(result), &outl, strict)) {
- zend_string_free(result);
+ zend_string_efree(result);
return NULL;
}
@@ -722,7 +722,7 @@ zend_string *php_base64_decode_ex_ssse3(const unsigned char *str, size_t length,
PHP_BASE64_DECODE_SSSE3_LOOP;
if (!php_base64_decode_impl(c, length, (unsigned char*)ZSTR_VAL(result), &outl, strict)) {
- zend_string_free(result);
+ zend_string_efree(result);
return NULL;
}
@@ -767,7 +767,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
result = zend_string_alloc(length, 0);
if (!php_base64_decode_impl(str, length, (unsigned char*)ZSTR_VAL(result), &outl, strict)) {
- zend_string_free(result);
+ zend_string_efree(result);
return NULL;
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 740e7333ed..85aa81f873 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -5618,7 +5618,7 @@ PHP_FUNCTION(restore_include_path)
}
key = zend_string_init("include_path", sizeof("include_path")-1, 0);
zend_restore_ini_entry(key, PHP_INI_STAGE_RUNTIME);
- zend_string_free(key);
+ zend_string_efree(key);
}
/* }}} */
diff --git a/ext/standard/file.c b/ext/standard/file.c
index bb497616e0..096d70e12c 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -1047,7 +1047,7 @@ PHPAPI PHP_FUNCTION(fgets)
str = zend_string_alloc(len, 0);
if (php_stream_get_line(stream, ZSTR_VAL(str), len, &line_len) == NULL) {
- zend_string_free(str);
+ zend_string_efree(str);
RETURN_FALSE;
}
/* resize buffer if it's much larger than the result.
diff --git a/ext/standard/html.c b/ext/standard/html.c
index f911b34388..3e3f269c04 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -1294,7 +1294,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle
len += replacement_len;
continue;
} else {
- zend_string_free(replaced);
+ zend_string_efree(replaced);
return ZSTR_EMPTY_ALLOC();
}
} else { /* SUCCESS */
diff --git a/ext/standard/info.c b/ext/standard/info.c
index f0c8bcfd7b..5c5892e6b6 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -257,7 +257,7 @@ static void php_print_gpcse_array(char *name, uint32_t name_length)
}
} ZEND_HASH_FOREACH_END();
}
- zend_string_free(key);
+ zend_string_efree(key);
}
/* }}} */
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index 85a5bb4475..5a6c422a4a 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -229,7 +229,7 @@ PHP_FUNCTION(iptcembed)
if (php_iptc_get1(fp, spool, poi?&poi:0) != 0xFF) {
fclose(fp);
if (spoolbuf) {
- zend_string_free(spoolbuf);
+ zend_string_efree(spoolbuf);
}
RETURN_FALSE;
}
@@ -237,7 +237,7 @@ PHP_FUNCTION(iptcembed)
if (php_iptc_get1(fp, spool, poi?&poi:0) != 0xD8) {
fclose(fp);
if (spoolbuf) {
- zend_string_free(spoolbuf);
+ zend_string_efree(spoolbuf);
}
RETURN_FALSE;
}
diff --git a/ext/standard/net.c b/ext/standard/net.c
index f4def94e01..d1e78dcc7a 100644
--- a/ext/standard/net.c
+++ b/ext/standard/net.c
@@ -56,7 +56,7 @@ PHPAPI zend_string* php_inet_ntop(const struct sockaddr *addr) {
ZSTR_LEN(ret) = strlen(ZSTR_VAL(ret));
return ret;
}
- zend_string_free(ret);
+ zend_string_efree(ret);
break;
}
#endif
@@ -66,7 +66,7 @@ PHPAPI zend_string* php_inet_ntop(const struct sockaddr *addr) {
ZSTR_LEN(ret) = strlen(ZSTR_VAL(ret));
return ret;
}
- zend_string_free(ret);
+ zend_string_efree(ret);
break;
}
}
@@ -88,7 +88,7 @@ PHPAPI zend_string* php_inet_ntop(const struct sockaddr *addr) {
ZSTR_LEN(ret) = strlen(ZSTR_VAL(ret));
return ret;
}
- zend_string_free(ret);
+ zend_string_efree(ret);
break;
}
}
diff --git a/ext/standard/password.c b/ext/standard/password.c
index dff62f6d8e..105abbc565 100644
--- a/ext/standard/password.c
+++ b/ext/standard/password.c
@@ -544,13 +544,13 @@ PHP_FUNCTION(password_hash)
zend_string_release(salt);
if (status != ARGON2_OK) {
- zend_string_free(encoded);
+ zend_string_efree(encoded);
php_error_docref(NULL, E_WARNING, "%s", argon2_error_message(status));
RETURN_FALSE;
}
ZSTR_VAL(encoded)[ZSTR_LEN(encoded)] = 0;
- RETURN_STR(encoded);
+ RETURN_NEW_STR(encoded);
}
break;
#endif
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index fa82e74874..d3f0c1cd7c 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -419,7 +419,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
RETURN_NEW_STR(read_buf);
}
- zend_string_free(read_buf);
+ zend_string_efree(read_buf);
RETURN_FALSE;
}
/* }}} */
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 0f6780fff0..f43d44929b 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -164,7 +164,7 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
if (EXPECTED((((c ^ '0') - 10) >> (8 * sizeof(unsigned int) - 1)) | is_letter)) {
d = (l - 0x10 - 0x27 * is_letter) << 4;
} else {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
c = old[j++];
@@ -173,7 +173,7 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
if (EXPECTED((((c ^ '0') - 10) >> (8 * sizeof(unsigned int) - 1)) | is_letter)) {
d |= l - 0x10 - 0x27 * is_letter;
} else {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
ret[i] = d;
@@ -1666,7 +1666,7 @@ PHP_FUNCTION(dirname)
#endif
} else if (levels < 1) {
php_error_docref(NULL, E_WARNING, "Invalid argument, levels must be >= 1");
- zend_string_free(ret);
+ zend_string_efree(ret);
return;
} else {
/* Some levels up */
@@ -6025,7 +6025,7 @@ PHP_FUNCTION(money_format)
str = zend_string_safe_alloc(format_len, 1, 1024, 0);
if ((res_len = strfmon(ZSTR_VAL(str), ZSTR_LEN(str), format, value)) < 0) {
- zend_string_free(str);
+ zend_string_efree(str);
RETURN_FALSE;
}
#ifdef _AIX
diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c
index 74fc250303..e9714d28e1 100644
--- a/ext/standard/uuencode.c
+++ b/ext/standard/uuencode.c
@@ -192,7 +192,7 @@ PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */
return dest;
err:
- zend_string_free(dest);
+ zend_string_efree(dest);
return NULL;
}
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index aa632d04f1..b6b3f57db1 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -252,13 +252,13 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t
unsigned char *end = *(unsigned char **)p+maxlen;
if (end < *p) {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
for (i = 0; i < len; i++) {
if (*p >= end) {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
if (**p != '\\') {
@@ -275,7 +275,7 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t
} else if (**p >= 'A' && **p <= 'F') {
ch = (ch << 4) + (**p -'A'+10);
} else {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
}
@@ -1341,7 +1341,7 @@ yy80:
}
if (*(YYCURSOR) != '"') {
- zend_string_free(str);
+ zend_string_efree(str);
*p = YYCURSOR;
return 0;
}
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index 6606ebe009..8e238dae6e 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -250,13 +250,13 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t
unsigned char *end = *(unsigned char **)p+maxlen;
if (end < *p) {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
for (i = 0; i < len; i++) {
if (*p >= end) {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
if (**p != '\\') {
@@ -273,7 +273,7 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t
} else if (**p >= 'A' && **p <= 'F') {
ch = (ch << 4) + (**p -'A'+10);
} else {
- zend_string_free(str);
+ zend_string_efree(str);
return NULL;
}
}
@@ -848,7 +848,7 @@ use_double:
}
if (*(YYCURSOR) != '"') {
- zend_string_free(str);
+ zend_string_efree(str);
*p = YYCURSOR;
return 0;
}
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index afb033f130..815f64ecb4 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1328,7 +1328,7 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read)
ZSTR_LEN(buffer) = n;
RETURN_NEW_STR(buffer);
} else {
- zend_string_free(buffer);
+ zend_string_efree(buffer);
RETURN_EMPTY_STRING()
}
} else {
@@ -2860,7 +2860,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
buffer = zend_string_safe_alloc(1, len, 0, 0);
n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
if (n < 1) {
- zend_string_free(buffer);
+ zend_string_efree(buffer);
RETURN_EMPTY_STRING();
}
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index fde9f02ffa..dd38fa6857 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -362,7 +362,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod
ZSTR_VAL(out)[ZSTR_LEN(out)] = '\0';
return out;
} else {
- zend_string_free(out);
+ zend_string_efree(out);
}
}
diff --git a/main/php_variables.c b/main/php_variables.c
index 9e7f185bd9..09e5afcf3b 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -600,7 +600,7 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array)
for (i = 0; i < SG(request_info).argc; i++) {
ZVAL_STRING(&tmp, SG(request_info).argv[i]);
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
- zend_string_free(Z_STR(tmp));
+ zend_string_efree(Z_STR(tmp));
}
}
} else if (s && *s) {
@@ -614,7 +614,7 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array)
ZVAL_STRING(&tmp, ss);
count++;
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
- zend_string_free(Z_STR(tmp));
+ zend_string_efree(Z_STR(tmp));
}
if (space) {
*space = '+';