Skip to content

Commit b6cc4d2

Browse files
committed
Use zval_ptr_dtor() instead of zval_dtor() in internal functions that destroy new created object (This is safer and produces less code)
1 parent 265c3ed commit b6cc4d2

File tree

14 files changed

+37
-37
lines changed

14 files changed

+37
-37
lines changed

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3897,7 +3897,7 @@ PHP_METHOD(DateTimeZone, __set_state)
38973897
tzobj = Z_PHPTIMEZONE_P(return_value);
38983898
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) {
38993899
zend_throw_error(NULL, "Timezone initialization failed");
3900-
zval_dtor(return_value);
3900+
zval_ptr_dtor(return_value);
39013901
}
39023902
}
39033903
/* }}} */

ext/gmp/gmp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ ZEND_FUNCTION(gmp_init)
10541054

10551055
INIT_GMP_RETVAL(gmpnumber);
10561056
if (convert_to_gmp(gmpnumber, number_arg, base) == FAILURE) {
1057-
zval_dtor(return_value);
1057+
zval_ptr_dtor(return_value);
10581058
RETURN_FALSE;
10591059
}
10601060
}
@@ -1770,7 +1770,7 @@ ZEND_FUNCTION(gmp_invert)
17701770
FREE_GMP_TEMP(temp_a);
17711771
FREE_GMP_TEMP(temp_b);
17721772
if (!res) {
1773-
zval_dtor(return_value);
1773+
zval_ptr_dtor(return_value);
17741774
RETURN_FALSE;
17751775
}
17761776
}

ext/hash/hash.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,27 +340,27 @@ static void php_hashcontext_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *objval) {
340340
php_hashcontext_object *hash = php_hashcontext_from_object(Z_OBJ_P(objval));
341341

342342
if (zend_parse_parameters(argc, "S|lS", &algo, &options, &key) == FAILURE) {
343-
zval_dtor(return_value);
343+
zval_ptr_dtor(return_value);
344344
RETURN_NULL();
345345
}
346346

347347
ops = php_hash_fetch_ops(ZSTR_VAL(algo), ZSTR_LEN(algo));
348348
if (!ops) {
349349
php_error_docref(NULL, E_WARNING, "Unknown hashing algorithm: %s", ZSTR_VAL(algo));
350-
zval_dtor(return_value);
350+
zval_ptr_dtor(return_value);
351351
RETURN_FALSE;
352352
}
353353

354354
if (options & PHP_HASH_HMAC) {
355355
if (!ops->is_crypto) {
356356
php_error_docref(NULL, E_WARNING, "HMAC requested with a non-cryptographic hashing algorithm: %s", ZSTR_VAL(algo));
357-
zval_dtor(return_value);
357+
zval_ptr_dtor(return_value);
358358
RETURN_FALSE;
359359
}
360360
if (!key || (ZSTR_LEN(key) == 0)) {
361361
/* Note: a zero length key is no key at all */
362362
php_error_docref(NULL, E_WARNING, "HMAC requested without a key");
363-
zval_dtor(return_value);
363+
zval_ptr_dtor(return_value);
364364
RETURN_FALSE;
365365
}
366366
}
@@ -580,7 +580,7 @@ PHP_FUNCTION(hash_copy)
580580
RETVAL_OBJ(Z_OBJ_HANDLER_P(zhash, clone_obj)(zhash));
581581

582582
if (php_hashcontext_from_object(Z_OBJ_P(return_value))->context == NULL) {
583-
zval_dtor(return_value);
583+
zval_ptr_dtor(return_value);
584584
RETURN_FALSE;
585585
}
586586
}

ext/imap/php_imap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3339,7 +3339,7 @@ PHP_FUNCTION(imap_bodystruct)
33393339

33403340
body=mail_body(imap_le_struct->imap_stream, msg, (unsigned char*)ZSTR_VAL(section));
33413341
if (body == NULL) {
3342-
zval_dtor(return_value);
3342+
zval_ptr_dtor(return_value);
33433343
RETURN_FALSE;
33443344
}
33453345
if (body->type <= TYPEMAX) {

ext/intl/calendar/gregoriancalendar_methods.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void _php_intlgregcal_constructor_body(
6565
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
6666
"intlgregcal_create_instance: too many arguments", 0);
6767
if (!is_constructor) {
68-
zval_dtor(return_value);
68+
zval_ptr_dtor(return_value);
6969
RETVAL_NULL();
7070
}
7171
return;
@@ -78,7 +78,7 @@ static void _php_intlgregcal_constructor_body(
7878
"intlgregcal_create_instance: no variant with 4 arguments "
7979
"(excluding trailing NULLs)", 0);
8080
if (!is_constructor) {
81-
zval_dtor(return_value);
81+
zval_ptr_dtor(return_value);
8282
RETVAL_NULL();
8383
}
8484
return;
@@ -91,7 +91,7 @@ static void _php_intlgregcal_constructor_body(
9191
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
9292
"intlgregcal_create_instance: bad arguments", 0);
9393
if (!is_constructor) {
94-
zval_dtor(return_value);
94+
zval_ptr_dtor(return_value);
9595
RETVAL_NULL();
9696
}
9797
return;
@@ -103,7 +103,7 @@ static void _php_intlgregcal_constructor_body(
103103
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
104104
"intlgregcal_create_instance: bad arguments", 0);
105105
if (!is_constructor) {
106-
zval_dtor(return_value);
106+
zval_ptr_dtor(return_value);
107107
RETVAL_NULL();
108108
}
109109
return;
@@ -121,7 +121,7 @@ static void _php_intlgregcal_constructor_body(
121121
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
122122
}
123123
if (!is_constructor) {
124-
zval_dtor(return_value);
124+
zval_ptr_dtor(return_value);
125125
RETVAL_NULL();
126126
}
127127
return;
@@ -140,7 +140,7 @@ static void _php_intlgregcal_constructor_body(
140140
}
141141
delete tz;
142142
if (!is_constructor) {
143-
zval_dtor(return_value);
143+
zval_ptr_dtor(return_value);
144144
RETVAL_NULL();
145145
}
146146
return;
@@ -153,7 +153,7 @@ static void _php_intlgregcal_constructor_body(
153153
"intlgregcal_create_instance: at least one of the arguments"
154154
" has an absolute value that is too large", 0);
155155
if (!is_constructor) {
156-
zval_dtor(return_value);
156+
zval_ptr_dtor(return_value);
157157
RETVAL_NULL();
158158
}
159159
return;
@@ -178,7 +178,7 @@ static void _php_intlgregcal_constructor_body(
178178
delete gcal;
179179
}
180180
if (!is_constructor) {
181-
zval_dtor(return_value);
181+
zval_ptr_dtor(return_value);
182182
RETVAL_NULL();
183183
}
184184
return;
@@ -198,7 +198,7 @@ static void _php_intlgregcal_constructor_body(
198198
0);
199199
delete gcal;
200200
if (!is_constructor) {
201-
zval_dtor(return_value);
201+
zval_ptr_dtor(return_value);
202202
RETVAL_NULL();
203203
}
204204
return;

ext/intl/resourcebundle/resourcebundle_class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constr
105105

106106
if (bundlename_len >= MAXPATHLEN) {
107107
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "Bundle name too long", 0 );
108-
zval_dtor(return_value);
108+
zval_ptr_dtor(return_value);
109109
ZVAL_NULL(return_value);
110110
return FAILURE;
111111
}

ext/intl/transliterator/transliterator_methods.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir
5353
{
5454
intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) );
5555
intl_error_set_custom_msg( NULL, "String conversion of id to UTF-16 failed", 0 );
56-
zval_dtor( object );
56+
zval_ptr_dtor( object );
5757
return FAILURE;
5858
}
5959

@@ -79,7 +79,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir
7979
intl_error_set_custom_msg( NULL, buf, /* copy message */ 1 );
8080
efree( buf );
8181
}
82-
zval_dtor( object );
82+
zval_ptr_dtor( object );
8383
return FAILURE;
8484
}
8585

@@ -90,7 +90,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir
9090
intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) );
9191
intl_error_set_custom_msg( NULL,
9292
"transliterator_create: internal constructor call failed", 0 );
93-
zval_dtor( object );
93+
zval_ptr_dtor( object );
9494
return FAILURE;
9595
}
9696

@@ -192,7 +192,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
192192
intl_errors_set_custom_msg( INTL_DATA_ERROR_P( to ), msg, 1 );
193193
efree( msg );
194194
}
195-
zval_dtor( return_value );
195+
zval_ptr_dtor( return_value );
196196
RETURN_NULL();
197197
}
198198
transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );

ext/openssl/openssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ PHP_FUNCTION(openssl_x509_parse)
24372437
BIO_get_mem_ptr(bio_out, &bio_buf);
24382438
add_assoc_stringl(&subitem, extname, bio_buf->data, bio_buf->length);
24392439
} else {
2440-
zval_dtor(return_value);
2440+
zend_array_destroy(Z_ARR_P(return_value));
24412441
BIO_free(bio_out);
24422442
if (Z_TYPE_P(zcert) != IS_RESOURCE) {
24432443
X509_free(cert);

ext/pdo/pdo_dbh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static PHP_METHOD(PDO, prepare)
549549
PDO_HANDLE_DBH_ERR();
550550

551551
/* kill the object handle for the stmt here */
552-
zval_dtor(return_value);
552+
zval_ptr_dtor(return_value);
553553

554554
RETURN_FALSE;
555555
}

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
11001100
} 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) {
11011101
zval_ptr_dtor(&val);
11021102
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class");
1103-
zval_dtor(return_value);
1103+
zval_ptr_dtor(return_value);
11041104
ZVAL_NULL(return_value);
11051105
return 0;
11061106
} else {

0 commit comments

Comments
 (0)