summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-07-05 11:54:26 +0300
committerDmitry Stogov <dmitry@zend.com>2018-07-05 11:54:26 +0300
commitb6cc4d2009a7df108c2858f28750d01e55c6de24 (patch)
tree2a5f9120e946fd932cf3f98104200a45feeeaa8a
parent265c3ed6cfd05b78fb65187f18b3e1ecb560c242 (diff)
downloadphp-git-b6cc4d2009a7df108c2858f28750d01e55c6de24.tar.gz
Use zval_ptr_dtor() instead of zval_dtor() in internal functions that destroy new created object (This is safer and produces less code)
-rw-r--r--ext/date/php_date.c2
-rw-r--r--ext/gmp/gmp.c4
-rw-r--r--ext/hash/hash.c10
-rw-r--r--ext/imap/php_imap.c2
-rw-r--r--ext/intl/calendar/gregoriancalendar_methods.cpp18
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c2
-rw-r--r--ext/intl/transliterator/transliterator_methods.c8
-rw-r--r--ext/openssl/openssl.c2
-rw-r--r--ext/pdo/pdo_dbh.c2
-rw-r--r--ext/pdo/pdo_stmt.c2
-rw-r--r--ext/reflection/php_reflection.c10
-rw-r--r--ext/soap/php_packet_soap.c2
-rw-r--r--ext/sqlite3/sqlite3.c8
-rw-r--r--main/streams/userspace.c2
14 files changed, 37 insertions, 37 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 6f7f138f8e..143faaf1c4 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -3897,7 +3897,7 @@ PHP_METHOD(DateTimeZone, __set_state)
tzobj = Z_PHPTIMEZONE_P(return_value);
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) {
zend_throw_error(NULL, "Timezone initialization failed");
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
}
}
/* }}} */
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 93c69d3347..761ca6f2f1 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -1054,7 +1054,7 @@ ZEND_FUNCTION(gmp_init)
INIT_GMP_RETVAL(gmpnumber);
if (convert_to_gmp(gmpnumber, number_arg, base) == FAILURE) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
}
@@ -1770,7 +1770,7 @@ ZEND_FUNCTION(gmp_invert)
FREE_GMP_TEMP(temp_a);
FREE_GMP_TEMP(temp_b);
if (!res) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
}
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index bf50ed6209..2d6192f6c6 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -340,27 +340,27 @@ static void php_hashcontext_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *objval) {
php_hashcontext_object *hash = php_hashcontext_from_object(Z_OBJ_P(objval));
if (zend_parse_parameters(argc, "S|lS", &algo, &options, &key) == FAILURE) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_NULL();
}
ops = php_hash_fetch_ops(ZSTR_VAL(algo), ZSTR_LEN(algo));
if (!ops) {
php_error_docref(NULL, E_WARNING, "Unknown hashing algorithm: %s", ZSTR_VAL(algo));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (options & PHP_HASH_HMAC) {
if (!ops->is_crypto) {
php_error_docref(NULL, E_WARNING, "HMAC requested with a non-cryptographic hashing algorithm: %s", ZSTR_VAL(algo));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (!key || (ZSTR_LEN(key) == 0)) {
/* Note: a zero length key is no key at all */
php_error_docref(NULL, E_WARNING, "HMAC requested without a key");
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
}
@@ -580,7 +580,7 @@ PHP_FUNCTION(hash_copy)
RETVAL_OBJ(Z_OBJ_HANDLER_P(zhash, clone_obj)(zhash));
if (php_hashcontext_from_object(Z_OBJ_P(return_value))->context == NULL) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
}
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index 86b0011f09..78b6ebd19c 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -3339,7 +3339,7 @@ PHP_FUNCTION(imap_bodystruct)
body=mail_body(imap_le_struct->imap_stream, msg, (unsigned char*)ZSTR_VAL(section));
if (body == NULL) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (body->type <= TYPEMAX) {
diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp
index 48745818b5..004d8e0c4f 100644
--- a/ext/intl/calendar/gregoriancalendar_methods.cpp
+++ b/ext/intl/calendar/gregoriancalendar_methods.cpp
@@ -65,7 +65,7 @@ static void _php_intlgregcal_constructor_body(
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: too many arguments", 0);
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -78,7 +78,7 @@ static void _php_intlgregcal_constructor_body(
"intlgregcal_create_instance: no variant with 4 arguments "
"(excluding trailing NULLs)", 0);
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -91,7 +91,7 @@ static void _php_intlgregcal_constructor_body(
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: bad arguments", 0);
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -103,7 +103,7 @@ static void _php_intlgregcal_constructor_body(
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: bad arguments", 0);
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -121,7 +121,7 @@ static void _php_intlgregcal_constructor_body(
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
}
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -140,7 +140,7 @@ static void _php_intlgregcal_constructor_body(
}
delete tz;
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -153,7 +153,7 @@ static void _php_intlgregcal_constructor_body(
"intlgregcal_create_instance: at least one of the arguments"
" has an absolute value that is too large", 0);
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -178,7 +178,7 @@ static void _php_intlgregcal_constructor_body(
delete gcal;
}
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
@@ -198,7 +198,7 @@ static void _php_intlgregcal_constructor_body(
0);
delete gcal;
if (!is_constructor) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETVAL_NULL();
}
return;
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index 0dd7047456..5b142a54d1 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -105,7 +105,7 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constr
if (bundlename_len >= MAXPATHLEN) {
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "Bundle name too long", 0 );
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
ZVAL_NULL(return_value);
return FAILURE;
}
diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c
index 6267b383ae..8bf7f9e7f2 100644
--- a/ext/intl/transliterator/transliterator_methods.c
+++ b/ext/intl/transliterator/transliterator_methods.c
@@ -53,7 +53,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir
{
intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) );
intl_error_set_custom_msg( NULL, "String conversion of id to UTF-16 failed", 0 );
- zval_dtor( object );
+ zval_ptr_dtor( object );
return FAILURE;
}
@@ -79,7 +79,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir
intl_error_set_custom_msg( NULL, buf, /* copy message */ 1 );
efree( buf );
}
- zval_dtor( object );
+ zval_ptr_dtor( object );
return FAILURE;
}
@@ -90,7 +90,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir
intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) );
intl_error_set_custom_msg( NULL,
"transliterator_create: internal constructor call failed", 0 );
- zval_dtor( object );
+ zval_ptr_dtor( object );
return FAILURE;
}
@@ -192,7 +192,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
intl_errors_set_custom_msg( INTL_DATA_ERROR_P( to ), msg, 1 );
efree( msg );
}
- zval_dtor( return_value );
+ zval_ptr_dtor( return_value );
RETURN_NULL();
}
transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 391b101f12..52f3ff6c67 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -2437,7 +2437,7 @@ PHP_FUNCTION(openssl_x509_parse)
BIO_get_mem_ptr(bio_out, &bio_buf);
add_assoc_stringl(&subitem, extname, bio_buf->data, bio_buf->length);
} else {
- zval_dtor(return_value);
+ zend_array_destroy(Z_ARR_P(return_value));
BIO_free(bio_out);
if (Z_TYPE_P(zcert) != IS_RESOURCE) {
X509_free(cert);
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index d4453c5012..9c92b5afb7 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -549,7 +549,7 @@ static PHP_METHOD(PDO, prepare)
PDO_HANDLE_DBH_ERR();
/* kill the object handle for the stmt here */
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index b4f08a87a3..5f198e15a2 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -1100,7 +1100,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
} else if (ce->unserialize(return_value, ce, (unsigned char *)(Z_TYPE(val) == IS_STRING ? Z_STRVAL(val) : ""), Z_TYPE(val) == IS_STRING ? Z_STRLEN(val) : 0, NULL) == FAILURE) {
zval_ptr_dtor(&val);
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class");
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
ZVAL_NULL(return_value);
return 0;
} else {
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a793536d8d..e57c388e4a 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -4672,12 +4672,12 @@ ZEND_METHOD(reflection_class, newInstance)
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_NULL();
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "*", &params, &num_args) == FAILURE) {
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -4704,7 +4704,7 @@ ZEND_METHOD(reflection_class, newInstance)
}
if (ret == FAILURE) {
php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ZSTR_VAL(ce->name));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_NULL();
}
} else if (ZEND_NUM_ARGS()) {
@@ -4769,7 +4769,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_NULL();
}
@@ -4805,7 +4805,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
if (ret == FAILURE) {
zval_ptr_dtor(&retval);
php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ZSTR_VAL(ce->name));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_NULL();
}
} else if (argc) {
diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c
index b72bde97f5..6e8a351c21 100644
--- a/ext/soap/php_packet_soap.c
+++ b/ext/soap/php_packet_soap.c
@@ -373,7 +373,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
if (Z_TYPE_P(return_value) == IS_ARRAY) {
if (param_count == 0) {
- zval_dtor(return_value);
+ zend_array_destroy(Z_ARR_P(return_value));
ZVAL_NULL(return_value);
} else if (param_count == 1) {
zval *tmp;
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index a4072aa175..08d436786f 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -485,7 +485,7 @@ PHP_METHOD(sqlite3, prepare)
errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL);
if (errcode != SQLITE_OK) {
php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -572,7 +572,7 @@ PHP_METHOD(sqlite3, query)
}
sqlite3_finalize(stmt_obj->stmt);
stmt_obj->initialised = 0;
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
}
@@ -1661,7 +1661,7 @@ PHP_METHOD(sqlite3stmt, execute)
if (!EG(exception)) {
php_sqlite3_error(stmt_obj->db_obj, "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(stmt_obj->stmt)));
}
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -1704,7 +1704,7 @@ PHP_METHOD(sqlite3stmt, __construct)
errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL);
if (errcode != SQLITE_OK) {
php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db));
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
stmt_obj->initialised = 1;
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 5f70e0ac73..21716095b2 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -317,7 +317,7 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php
if (zend_call_function(&fci, &fcc) == FAILURE) {
php_error_docref(NULL, E_WARNING, "Could not execute %s::%s()", ZSTR_VAL(uwrap->ce->name), ZSTR_VAL(uwrap->ce->constructor->common.function_name));
- zval_dtor(object);
+ zval_ptr_dtor(object);
ZVAL_UNDEF(object);
} else {
zval_ptr_dtor(&retval);