Replace zval_dtor() with specialized destructors

This commit is contained in:
Dmitry Stogov 2018-07-05 13:32:39 +03:00
parent 0d235517a3
commit b6fb584505
13 changed files with 45 additions and 43 deletions

View file

@ -320,11 +320,11 @@ static UBool enumCharNames_callback(enumCharNames_data *context,
intl_error_set_code(NULL, U_INTERNAL_PROGRAM_ERROR);
intl_error_set_custom_msg(NULL, "enumCharNames callback failed", 0);
zval_dtor(&retval);
zval_dtor(&args[2]);
zval_ptr_dtor_str(&args[2]);
return 0;
}
zval_dtor(&retval);
zval_dtor(&args[2]);
zval_ptr_dtor_str(&args[2]);
return 1;
}
IC_METHOD(enumCharNames) {

View file

@ -67,7 +67,7 @@ mysqlnd_minfo_dump_plugin_stats(zval *el, void * argument)
php_info_print_table_header(2, buf, "");
mysqlnd_minfo_print_hash(&values);
php_info_print_table_end();
zval_dtor(&values);
zend_array_destroy(Z_ARR(values));
}
return ZEND_HASH_APPLY_KEEP;
}

View file

@ -1180,7 +1180,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
}
zend_hash_next_index_insert(Z_ARRVAL(grp), return_value);
}
zval_dtor(&grp_val);
zval_ptr_dtor_str(&grp_val);
}
}
@ -2579,7 +2579,7 @@ static int row_prop_exists(zval *object, zval *member, int check_empty, void **c
fetch_value(stmt, &val, colno, NULL);
res = check_empty ? i_zend_is_true(&val) : Z_TYPE(val) != IS_NULL;
zval_dtor(&val);
zval_ptr_dtor_nogc(&val);
return res;
}

View file

@ -487,7 +487,7 @@ static int firebird_bind_blob(pdo_stmt_t *stmt, ISC_QUAD *blob_id, zval *param)
}
if (Z_TYPE_P(param) != IS_STRING) {
zval_dtor(&data);
zval_ptr_dtor_str(&data);
}
if (isc_close_blob(H->isc_status, &h)) {

View file

@ -1637,14 +1637,14 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
err = 1;
add_assoc_long_ex(&filterparams, "window", sizeof("window") - 1, MAX_WBITS);
filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp));
zval_dtor(&filterparams);
zend_array_destroy(Z_ARR(filterparams));
if (!filter) {
php_stream_close(temp);
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\", ext/zlib is buggy in PHP versions older than 5.2.6")
}
} else {
zval_dtor(&filterparams);
zend_array_destroy(Z_ARR(filterparams));
}
php_stream_filter_append(&temp->writefilters, filter);
@ -3191,7 +3191,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
array_init(&filterparams);
add_assoc_long(&filterparams, "window", MAX_WBITS+16);
filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp));
zval_dtor(&filterparams);
zend_array_destroy(Z_ARR(filterparams));
if (!filter) {
if (error) {

View file

@ -1320,7 +1320,7 @@ nostub:
#endif
add_assoc_long(&filterparams, "window", MAX_WBITS + 16);
filter = php_stream_filter_create("zlib.deflate", &filterparams, php_stream_is_persistent(phar->fp));
zval_dtor(&filterparams);
zend_array_destroy(Z_ARR(filterparams));
if (!filter) {
/* copy contents uncompressed rather than lose them */

View file

@ -1404,18 +1404,18 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t
}
if ((size_t)end != Z_STRLEN(zp[0])) {
zval_dtor(&zp[0]);
zval_dtor(&zp[1]);
zval_dtor(&zp[2]);
zval_dtor(&openssl);
zval_ptr_dtor_str(&zp[0]);
zval_ptr_dtor_str(&zp[1]);
zval_ptr_dtor_str(&zp[2]);
zval_ptr_dtor_str(&openssl);
return FAILURE;
}
if (FAILURE == zend_fcall_info_init(&openssl, 0, &fci, &fcc, NULL, NULL)) {
zval_dtor(&zp[0]);
zval_dtor(&zp[1]);
zval_dtor(&zp[2]);
zval_dtor(&openssl);
zval_ptr_dtor_str(&zp[0]);
zval_ptr_dtor_str(&zp[1]);
zval_ptr_dtor_str(&zp[2]);
zval_ptr_dtor_str(&openssl);
return FAILURE;
}
@ -1432,14 +1432,14 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t
fci.retval = &retval;
if (FAILURE == zend_call_function(&fci, &fcc)) {
zval_dtor(&zp[0]);
zval_dtor(&zp[1]);
zval_dtor(&zp[2]);
zval_dtor(&openssl);
zval_ptr_dtor_str(&zp[0]);
zval_ptr_dtor(&zp[1]);
zval_ptr_dtor_str(&zp[2]);
zval_ptr_dtor_str(&openssl);
return FAILURE;
}
zval_dtor(&openssl);
zval_ptr_dtor_str(&openssl);
Z_DELREF(zp[0]);
if (is_sign) {
@ -1449,13 +1449,13 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t
}
Z_DELREF(zp[2]);
zval_dtor(&zp[0]);
zval_dtor(&zp[2]);
zval_ptr_dtor_str(&zp[0]);
zval_ptr_dtor_str(&zp[2]);
switch (Z_TYPE(retval)) {
default:
case IS_LONG:
zval_dtor(&zp[1]);
zval_ptr_dtor(&zp[1]);
if (1 == Z_LVAL(retval)) {
return SUCCESS;
}
@ -1463,10 +1463,10 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t
case IS_TRUE:
*signature = estrndup(Z_STRVAL(zp[1]), Z_STRLEN(zp[1]));
*signature_len = Z_STRLEN(zp[1]);
zval_dtor(&zp[1]);
zval_ptr_dtor(&zp[1]);
return SUCCESS;
case IS_FALSE:
zval_dtor(&zp[1]);
zval_ptr_dtor(&zp[1]);
return FAILURE;
}
}

View file

@ -971,7 +971,7 @@ static xmlNodePtr to_xml_hexbin(encodeTypePtr type, zval *data, int style, xmlNo
xmlAddChild(ret, text);
efree(str);
if (data == &tmp) {
zval_dtor(&tmp);
zval_ptr_dtor_str(&tmp);
}
if (style == SOAP_ENCODED) {
@ -3069,7 +3069,9 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP
}
smart_str_free(&list);
efree(str);
if (data == &tmp) {zval_dtor(&tmp);}
if (data == &tmp) {
zval_ptr_dtor_str(&tmp);
}
}
return ret;
}

View file

@ -1539,7 +1539,7 @@ PHP_METHOD(SoapServer, handle)
}
zval_ptr_dtor(&param);
zval_dtor(&readfile);
zval_ptr_dtor_str(&readfile);
zval_dtor(&readfile_ret);
SOAP_SERVER_END_CODE();
@ -1588,7 +1588,7 @@ PHP_METHOD(SoapServer, handle)
add_assoc_long_ex(&filter_params, "window", sizeof("window")-1, 0x2f); /* ANY WBITS */
zf = php_stream_filter_create("zlib.inflate", &filter_params, 0);
zval_dtor(&filter_params);
zend_array_destroy(Z_ARR(filter_params));
if (zf) {
php_stream_filter_append(&SG(request_info).request_body->readfilters, zf);
@ -1698,12 +1698,12 @@ PHP_METHOD(SoapServer, handle)
if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, getThis());
zval_dtor(&constructor);
zval_ptr_dtor_str(&constructor);
zval_dtor(&c_ret);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_dtor(&constructor);
zval_ptr_dtor_str(&constructor);
zval_dtor(&c_ret);
} else {
int class_name_len = ZSTR_LEN(service->soap_class.ce->name);
@ -1721,14 +1721,14 @@ PHP_METHOD(SoapServer, handle)
if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, getThis());
zval_dtor(&constructor);
zval_ptr_dtor_str(&constructor);
zval_dtor(&c_ret);
efree(class_name);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_dtor(&constructor);
zval_ptr_dtor_str(&constructor);
zval_dtor(&c_ret);
}
efree(class_name);
@ -1952,7 +1952,7 @@ fail:
}
efree(h->parameters);
}
zval_dtor(&h->function_name);
zval_ptr_dtor_str(&h->function_name);
zval_dtor(&h->retval);
efree(h);
}
@ -1965,7 +1965,7 @@ fail:
}
efree(params);
}
zval_dtor(&function_name);
zval_ptr_dtor_str(&function_name);
SOAP_SERVER_END_CODE();
}

View file

@ -881,7 +881,7 @@ PHP_MINFO_FUNCTION(spl)
SPL_LIST_CLASSES(&list, 0, 1, ZEND_ACC_INTERFACE)
strg = estrdup("");
zend_hash_apply_with_argument(Z_ARRVAL_P(&list), (apply_func_arg_t)spl_build_class_list_string, &strg);
zval_dtor(&list);
zend_array_destroy(Z_ARR(list));
php_info_print_table_row(2, "Interfaces", strg + 2);
efree(strg);
@ -889,7 +889,7 @@ PHP_MINFO_FUNCTION(spl)
SPL_LIST_CLASSES(&list, 0, -1, ZEND_ACC_INTERFACE)
strg = estrdup("");
zend_hash_apply_with_argument(Z_ARRVAL_P(&list), (apply_func_arg_t)spl_build_class_list_string, &strg);
zval_dtor(&list);
zend_array_destroy(Z_ARR(list));
php_info_print_table_row(2, "Classes", strg + 2);
efree(strg);

View file

@ -5998,7 +5998,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
}
if (Z_TYPE_P(find_hash) != IS_ARRAY) {
zval_dtor(find_hash);
zval_ptr_dtor_nogc(find_hash);
array_init(find_hash);
}

View file

@ -700,7 +700,7 @@ PHP_FUNCTION(file_put_contents)
php_error_docref(NULL, E_WARNING, "Only "ZEND_LONG_FMT" of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out));
numbytes = -1;
}
zval_dtor(&out);
zval_ptr_dtor_str(&out);
break;
}
}

View file

@ -314,7 +314,7 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */
phpdbg_writeln("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_P(file), Z_LVAL_P(line));
phpdbg_xml("</backtrace>");
zval_dtor(&zbacktrace);
zval_ptr_dtor_nogc(&zbacktrace);
zend_string_release(Z_STR(startfile));
PHPDBG_OUTPUT_BACKUP_RESTORE();