]> granicus.if.org Git - php/commitdiff
Use zval_ptr_dtor() instead of zval_dtor() in internal functions that destroy new...
authorDmitry Stogov <dmitry@zend.com>
Thu, 5 Jul 2018 08:54:26 +0000 (11:54 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 5 Jul 2018 08:54:26 +0000 (11:54 +0300)
14 files changed:
ext/date/php_date.c
ext/gmp/gmp.c
ext/hash/hash.c
ext/imap/php_imap.c
ext/intl/calendar/gregoriancalendar_methods.cpp
ext/intl/resourcebundle/resourcebundle_class.c
ext/intl/transliterator/transliterator_methods.c
ext/openssl/openssl.c
ext/pdo/pdo_dbh.c
ext/pdo/pdo_stmt.c
ext/reflection/php_reflection.c
ext/soap/php_packet_soap.c
ext/sqlite3/sqlite3.c
main/streams/userspace.c

index 6f7f138f8e2519d43127d760369f4fbfa1637b11..143faaf1c46a9b614820dd7f416fae248a1f7b93 100644 (file)
@@ -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);
        }
 }
 /* }}} */
index 93c69d33479d513a1f1db2c4694c238afdb6a216..761ca6f2f1ae79856bf219ee425a51978c6129eb 100644 (file)
@@ -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;
        }
 }
index bf50ed6209402a603d23da03a0a99b9e7635428f..2d6192f6c67c70035952d610ed5f70128a8144c8 100644 (file)
@@ -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;
        }
 }
index 86b0011f094776d025bf9ca363b5f2c8efb94ab1..78b6ebd19c8c412224a08cfbb17f805deca50ef7 100644 (file)
@@ -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) {
index 48745818b5f37df8305c8e11f5fde52e37d6f4ac..004d8e0c4fca6cda0b7936c14d5ac65b39f0eab1 100644 (file)
@@ -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;
index 0dd704745663e1b0e27251069b861c91e8289144..5b142a54d1d5186a283bf7f3b59018c2c4c59e8e 100644 (file)
@@ -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;
        }
index 6267b383ae3cab5ed91fcbd5e52525329e536b20..8bf7f9e7f2e1445cb593cb1ba9e4fbc842fb12b2 100644 (file)
@@ -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 ) );
index 391b101f128a8a7e91edcd82fc167afa0abe231d..52f3ff6c67ad6273311b48f0bb0588c70ee2eafa 100644 (file)
@@ -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);
index d4453c5012ee1197272d55b7486cdf540d773524..9c92b5afb7b8bb385205f55a820f133cc5a28790 100644 (file)
@@ -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;
 }
index b4f08a87a3f58fe2c27af115deee7bbb086db6dc..5f198e15a26f3819c52ee5e2f6385355fedc31f9 100644 (file)
@@ -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 {
index a793536d8d76bde89bf7171ba565b055f52f0e86..e57c388e4a5ccce3ed9696eae1bd789a7ccb28e9 100644 (file)
@@ -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) {
index b72bde97f5ce455308601f1728cf5375a12584bf..6e8a351c21f26a059ef56132d8a6ed664cd7c336 100644 (file)
@@ -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;
index a4072aa175b30c21e7120c67759d1cd4df1da3e7..08d436786fcd6b10b8a8492a71c276f5fd55c186 100644 (file)
@@ -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;
index 5f70e0ac73a89a722cd827eefc47968a24e9cbea..21716095b21a17cef669ac820627bda7dabda19f 100644 (file)
@@ -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);