]> granicus.if.org Git - php/commitdiff
Accept zend_object in zend_read_property
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 7 Aug 2020 13:05:24 +0000 (15:05 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 7 Aug 2020 14:40:27 +0000 (16:40 +0200)
14 files changed:
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_exceptions.c
ext/com_dotnet/com_wrapper.c
ext/curl/curl_file.c
ext/curl/interface.c
ext/dom/php_dom.c
ext/reflection/php_reflection.c
ext/soap/php_encoding.c
ext/soap/soap.c
ext/sodium/libsodium.c
ext/spl/spl_iterators.c
sapi/cli/php_cli.c
sapi/phpdbg/phpdbg_prompt.c

index 9906d7b423bc84c585e2a46d67ddc369ae0e435c..bd45b093cf4a93f94d6a67012dc197bffd6d9979 100644 (file)
@@ -4179,21 +4179,21 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const
 }
 /* }}} */
 
-ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv) /* {{{ */
+ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv) /* {{{ */
 {
        zval *value;
        zend_class_entry *old_scope = EG(fake_scope);
 
        EG(fake_scope) = scope;
 
-       value = Z_OBJ_HT_P(object)->read_property(Z_OBJ_P(object), name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
+       value = object->handlers->read_property(object, name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
 
        EG(fake_scope) = old_scope;
        return value;
 }
 /* }}} */
 
-ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv) /* {{{ */
+ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent, zval *rv) /* {{{ */
 {
        zval *value;
        zend_string *str;
index 916a2ab425688c129d7b7b8acbe7a06cb02dacca..4d5de411bf03803d0c104e107913ad36e3b79639 100644 (file)
@@ -400,8 +400,8 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const c
 ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value);
 ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length);
 
-ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv);
-ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
+ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv);
+ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
 
 ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, zend_bool silent);
 ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
index d617bae108588b90ba2b25b4485af31e1a5846c2..aa0c8e64a414a9393d1d29dc6c3472d5e236c13c 100644 (file)
@@ -99,16 +99,16 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
        ZVAL_OBJ(&zv, exception);
        ex = &zv;
        do {
-               ancestor = zend_read_property_ex(i_get_exception_base(&pv), &pv, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
+               ancestor = zend_read_property_ex(i_get_exception_base(&pv), Z_OBJ(pv), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
                while (Z_TYPE_P(ancestor) == IS_OBJECT) {
                        if (Z_OBJ_P(ancestor) == Z_OBJ_P(ex)) {
                                OBJ_RELEASE(add_previous);
                                return;
                        }
-                       ancestor = zend_read_property_ex(i_get_exception_base(ancestor), ancestor, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
+                       ancestor = zend_read_property_ex(i_get_exception_base(ancestor), Z_OBJ_P(ancestor), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
                }
                base_ce = i_get_exception_base(ex);
-               previous = zend_read_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
+               previous = zend_read_property_ex(base_ce, Z_OBJ_P(ex), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
                if (Z_TYPE_P(previous) == IS_NULL) {
                        zend_update_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), &pv);
                        GC_DELREF(add_previous);
@@ -309,7 +309,7 @@ ZEND_METHOD(Exception, __construct)
 
 /* {{{ Exception unserialize checks */
 #define CHECK_EXC_TYPE(id, type) \
-       pvalue = zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 1, &value); \
+       pvalue = zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &value); \
        if (Z_TYPE_P(pvalue) != IS_NULL && Z_TYPE_P(pvalue) != type) { \
                zend_unset_property(i_get_exception_base(object), object, ZSTR_VAL(ZSTR_KNOWN(id)), ZSTR_LEN(ZSTR_KNOWN(id))); \
        }
@@ -375,9 +375,9 @@ ZEND_METHOD(ErrorException, __construct)
 /* }}} */
 
 #define GET_PROPERTY(object, id) \
-       zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 0, &rv)
+       zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 0, &rv)
 #define GET_PROPERTY_SILENT(object, id) \
-       zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 1, &rv)
+       zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv)
 
 /* {{{ Get the file in which the exception occurred */
 ZEND_METHOD(Exception, getFile)
@@ -603,7 +603,7 @@ ZEND_METHOD(Exception, getTraceAsString)
        object = ZEND_THIS;
        base_ce = i_get_exception_base(object);
 
-       trace = zend_read_property_ex(base_ce, object, ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv);
+       trace = zend_read_property_ex(base_ce, Z_OBJ_P(object), ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv);
        if (EG(exception)) {
                RETURN_THROWS();
        }
index c4f41a4916afe3897cebfbf346fc7fd1a4aa07e4..05ffb41f265d6645ae09a1ee8fb937679ac21efc 100644 (file)
@@ -278,7 +278,7 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
                 * and expose it as a COM exception */
 
                if (wFlags & DISPATCH_PROPERTYGET) {
-                       retval = zend_read_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv);
+                       retval = zend_read_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv);
                } else if (wFlags & DISPATCH_PROPERTYPUT) {
                        zend_update_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name), &params[0]);
                } else if (wFlags & DISPATCH_METHOD) {
index 7f31451f55f82cb3bf00d2edf0a80f64c0b4de22..950b670d84ec22bfed2ef13176a6e526c88ce4c4 100644 (file)
@@ -71,7 +71,7 @@ static void curlfile_get_property(char *name, size_t name_len, INTERNAL_FUNCTION
        zval *res, rv;
 
        ZEND_PARSE_PARAMETERS_NONE();
-       res = zend_read_property(curl_CURLFile_class, ZEND_THIS, name, name_len, 1, &rv);
+       res = zend_read_property(curl_CURLFile_class, Z_OBJ_P(ZEND_THIS), name, name_len, 1, &rv);
        ZVAL_COPY_DEREF(return_value, res);
 }
 
index f8edbefa2f15d014c9d38320d7274e1353e9e72e..8621c23b2b54f65d4aece7012fe4eeeba20fbb79 100644 (file)
@@ -2047,7 +2047,7 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
                        curl_seek_callback seekfunc = seek_cb;
 #endif
 
-                       prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
+                       prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "name", sizeof("name")-1, 0, &rv);
                        if (Z_TYPE_P(prop) != IS_STRING) {
                                php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key));
                        } else {
@@ -2057,11 +2057,11 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
                                        return 1;
                                }
 
-                               prop = zend_read_property(curl_CURLFile_class, current, "mime", sizeof("mime")-1, 0, &rv);
+                               prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "mime", sizeof("mime")-1, 0, &rv);
                                if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
                                        type = Z_STRVAL_P(prop);
                                }
-                               prop = zend_read_property(curl_CURLFile_class, current, "postname", sizeof("postname")-1, 0, &rv);
+                               prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "postname", sizeof("postname")-1, 0, &rv);
                                if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
                                        filename = Z_STRVAL_P(prop);
                                }
index 054240acd91e88658680146a49c3de8f958ef80c..8eae00fc03bbed66cac691e721b5591693d46aad 100644 (file)
@@ -1539,11 +1539,8 @@ static int dom_nodelist_has_dimension(zend_object *object, zval *member, int che
        if (offset < 0) {
                return 0;
        } else {
-               zval obj;
-               zval *length;
-
-               ZVAL_OBJ(&obj, object);
-               length = zend_read_property(object->ce, &obj, "length", sizeof("length") - 1, 0, &rv);
+               zval *length = zend_read_property(
+                       object->ce, object, "length", sizeof("length") - 1, 0, &rv);
                return length && offset < Z_LVAL_P(length);
        }
 } /* }}} end dom_nodelist_has_dimension */
index f11198f27d53936f503c7ebbde7d76f3c8e61392..4d860c2a58a82220c06ec1c6586e711e08a59ca7 100644 (file)
@@ -5316,7 +5316,7 @@ ZEND_METHOD(ReflectionProperty, getValue)
                        RETURN_THROWS();
                }
 
-               member_p = zend_read_property_ex(intern->ce, object, ref->unmangled_name, 0, &rv);
+               member_p = zend_read_property_ex(intern->ce, Z_OBJ_P(object), ref->unmangled_name, 0, &rv);
                if (member_p != &rv) {
                        ZVAL_COPY_DEREF(return_value, member_p);
                } else {
index 4a7dc2ad801003e828af5a38c0518aee880629a3..d189b3f282ed94c8552c589ec510bf0f238a42eb 100644 (file)
@@ -1170,7 +1170,7 @@ static void set_zval_property(zval* object, char* name, zval* val)
 static zval* get_zval_property(zval* object, char* name, zval *rv)
 {
        if (Z_TYPE_P(object) == IS_OBJECT) {
-               zval *data = zend_read_property(Z_OBJCE_P(object), object, name, strlen(name), 1, rv);
+               zval *data = zend_read_property(Z_OBJCE_P(object), Z_OBJ_P(object), name, strlen(name), 1, rv);
                if (data == &EG(uninitialized_zval)) {
                        return NULL;
                }
index af9b26161f67b9868642a13d4e6fc6bd3cdeaa89..8dc05c38029e52cc71f776d2f8309383cefabced 100644 (file)
@@ -643,10 +643,10 @@ PHP_METHOD(SoapFault, __toString)
        }
 
        this_ptr = ZEND_THIS;
-       faultcode   = zend_read_property(soap_fault_class_entry, this_ptr, "faultcode", sizeof("faultcode")-1, 1, &rv1);
-       faultstring = zend_read_property(soap_fault_class_entry, this_ptr, "faultstring", sizeof("faultstring")-1, 1, &rv2);
-       file = zend_read_property(soap_fault_class_entry, this_ptr, "file", sizeof("file")-1, 1, &rv3);
-       line = zend_read_property(soap_fault_class_entry, this_ptr, "line", sizeof("line")-1, 1, &rv4);
+       faultcode = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "faultcode", sizeof("faultcode")-1, 1, &rv1);
+       faultstring = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "faultstring", sizeof("faultstring")-1, 1, &rv2);
+       file = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "file", sizeof("file")-1, 1, &rv3);
+       line = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "line", sizeof("line")-1, 1, &rv4);
 
        zend_call_method_with_0_params(
                Z_OBJ_P(ZEND_THIS), Z_OBJCE_P(ZEND_THIS), NULL, "gettraceasstring", &trace);
@@ -1176,7 +1176,7 @@ static void _soap_server_exception(soapServicePtr service, sdlFunctionPtr functi
        } else if (instanceof_function(Z_OBJCE(exception_object), zend_ce_error)) {
                if (service->send_errors) {
                        zval rv;
-                       zend_string *msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
+                       zend_string *msg = zval_get_string(zend_read_property(zend_ce_error, Z_OBJ(exception_object), "message", sizeof("message")-1, 0, &rv));
                        add_soap_fault_ex(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL);
                        zend_string_release_ex(msg, 0);
                } else {
@@ -2241,7 +2241,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
                                zval exception_object;
 
                                ZVAL_OBJ(&exception_object, EG(exception));
-                               msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
+                               msg = zval_get_string(zend_read_property(zend_ce_error, Z_OBJ(exception_object), "message", sizeof("message")-1, 0, &rv));
                                /* change class */
                                EG(exception)->ce = soap_fault_class_entry;
                                set_soap_fault(&exception_object, NULL, "Client", ZSTR_VAL(msg), NULL, NULL, NULL);
index 93f1297c7468bda3aa8c663b6395310a49dfe709..ecb11d5f38ed090ccfd79b297637c4bbb1a485ac 100644 (file)
@@ -99,7 +99,7 @@ static void sodium_remove_param_values_from_backtrace(zend_object *obj) {
        zval obj_zv, rv, *trace;
 
        ZVAL_OBJ(&obj_zv, obj);
-       trace = zend_read_property(zend_get_exception_base(&obj_zv), &obj_zv, "trace", sizeof("trace")-1, 0, &rv);
+       trace = zend_read_property(zend_get_exception_base(&obj_zv), Z_OBJ(obj_zv), "trace", sizeof("trace")-1, 0, &rv);
        if (trace && Z_TYPE_P(trace) == IS_ARRAY) {
                zval *frame;
                ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(trace), frame) {
index c71f3cb14292a5dc681a7955ddf75c4cefcd10f3..2410050586696f06f5b4f6a275a54c0571d0df9f 100644 (file)
@@ -1863,7 +1863,7 @@ PHP_METHOD(RegexIterator, accept)
                        break;
 
                case REGIT_MODE_REPLACE: {
-                       zval *replacement = zend_read_property(intern->std.ce, ZEND_THIS, "replacement", sizeof("replacement")-1, 1, &rv);
+                       zval *replacement = zend_read_property(intern->std.ce, Z_OBJ_P(ZEND_THIS), "replacement", sizeof("replacement")-1, 1, &rv);
                        zend_string *replacement_str = zval_try_get_string(replacement);
                        if (UNEXPECTED(!replacement_str)) {
                                return;
index 845312e9c682e7ce01e7dc88bce06bf7ec259854..4874e0920cebeef15c8a55c1cc85b43fb4286061 100644 (file)
@@ -1067,12 +1067,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
                                                pce->constructor, Z_OBJ(ref), NULL, &arg);
 
                                        if (EG(exception)) {
-                                               zval tmp, *msg, rv;
-
-                                               ZVAL_OBJ(&tmp, EG(exception));
-                                               msg = zend_read_property(zend_ce_exception, &tmp, "message", sizeof("message")-1, 0, &rv);
+                                               zval rv;
+                                               zval *msg = zend_read_property(zend_ce_exception, EG(exception), "message", sizeof("message")-1, 0, &rv);
                                                zend_printf("Exception: %s\n", Z_STRVAL_P(msg));
-                                               zval_ptr_dtor(&tmp);
+                                               zend_object_release(EG(exception));
                                                EG(exception) = NULL;
                                        } else {
                                                zend_print_zval(&ref, 0);
index 9977adad4c573731dde292db2629e64326611016..76478592225b16a9505efa5e0160a1596a9d94a5 100644 (file)
@@ -726,8 +726,8 @@ static inline void phpdbg_handle_exception(void) /* {{{ */
 
        ZVAL_OBJ(&zv, ex);
        zend_call_known_instance_method_with_0_params(ex->ce->__tostring, ex, &tmp);
-       file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("file"), 1, &rv));
-       line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("line"), 1, &rv));
+       file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("file"), 1, &rv));
+       line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("line"), 1, &rv));
 
        if (EG(exception)) {
                EG(exception) = NULL;
@@ -735,7 +735,7 @@ static inline void phpdbg_handle_exception(void) /* {{{ */
        } else {
                zend_update_property_string(zend_get_exception_base(&zv), &zv, ZEND_STRL("string"), Z_STRVAL(tmp));
                zval_ptr_dtor(&tmp);
-               msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("string"), 1, &rv));
+               msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("string"), 1, &rv));
        }
 
        phpdbg_error("exception", "name=\"%s\" file=\"%s\" line=\"" ZEND_LONG_FMT "\"", "Uncaught %s in %s on line " ZEND_LONG_FMT, ZSTR_VAL(ex->ce->name), ZSTR_VAL(file), line);
@@ -1740,9 +1740,9 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
                        PHPDBG_G(handled_exception) = exception;
 
                        ZVAL_OBJ(&zv, exception);
-                       file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("file"), 1, &rv));
-                       line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("line"), 1, &rv));
-                       msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("message"), 1, &rv));
+                       file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("file"), 1, &rv));
+                       line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("line"), 1, &rv));
+                       msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("message"), 1, &rv));
 
                        phpdbg_error("exception",
                                "name=\"%s\" file=\"%s\" line=\"" ZEND_LONG_FMT "\"",