]> granicus.if.org Git - php/commitdiff
Replace zval_dtor() with specialized destructors
authorDmitry Stogov <dmitry@zend.com>
Thu, 5 Jul 2018 10:32:39 +0000 (13:32 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 5 Jul 2018 10:32:39 +0000 (13:32 +0300)
13 files changed:
ext/intl/uchar/uchar.c
ext/mysqlnd/php_mysqlnd.c
ext/pdo/pdo_stmt.c
ext/pdo_firebird/firebird_statement.c
ext/phar/phar.c
ext/phar/tar.c
ext/phar/util.c
ext/soap/php_encoding.c
ext/soap/soap.c
ext/spl/php_spl.c
ext/standard/basic_functions.c
ext/standard/file.c
sapi/phpdbg/phpdbg_frame.c

index 10bfbc25c108037493b5ced926e71be601f18918..b01018de447fd3fdf94c3b1ea4af94f6a8ac872c 100644 (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) {
index 4757990f6a8af5e5389c85f2b905b898d15949c7..53a85701d1b3c24590ee7ed46ca1b91263cf7510 100644 (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;
 }
index 5f198e15a26f3819c52ee5e2f6385355fedc31f9..a6b2bedc0bd91abfc53c54e92d2b91e45b85b1d2 100644 (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;
                        }
index 1d962411b7a656a1b22878b074bf7e3a63f1a9bc..43f0067916269e5bfa813604c955f68cfec2cf76 100644 (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)) {
index d0624bcc39e40c3ab3252a3979516d3c2b5ba6c1..499eca457dc82c95707d01ddf20ca1f372b6259a 100644 (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) {
index 4241298fe2abdc0ae8f30d68c788fef63cdd2c98..83e8fbcaff300d1455fb535c85fda34f593e6d32 100644 (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 */
index 7652846ecafd33e0f4fab55240faf97fada5d387..2044e9e6a87b0e1db4a2922724aab728534b11df 100644 (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;
        }
 }
index c2aaf367972a0f1e7a51505e04a7e91c9af1404f..0962e40118fa6a8865ee472c25a52b9ce247b31c 100644 (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;
 }
index b089caa6505885f3c9ae27af527af89582533315..82a4f369aca3fa05d7532a1e0678c646ad6d799c 100644 (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();
 }
index 37d1ecfc7ee41160380b34d74ee6cefab7ab00ce..f3acd6dd3d097b018058bcbb02495ed88357b9db 100644 (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);
 
index 6af26434b8d833fa11d280ceed03e5e0ebf5e9da..7424c24e1e76f4fc3c40543d0cdf1007921ab059 100644 (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);
                        }
 
index 5ed42dd2e5edda6fb59b764eccf081d1e9f72537..9507ae58277b2e087493af89a2b3b0fc795c1bb2 100644 (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;
                                }
                        }
index 7cdedcb4978dcb766ef3a7b13e2ec74c6710f282..2065277dfefd2ac4603eab68201faee9de64ecf5 100644 (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();