Previously it was possible that zend_read_property() returned pointer to zval allocated on stack.
}
/* }}} */
-ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent) /* {{{ */
+ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv) /* {{{ */
{
zval property, *value;
zend_class_entry *old_scope = EG(scope);
- zval rv;
EG(scope) = scope;
}
ZVAL_STRINGL(&property, name, name_length);
- value = Z_OBJ_HT_P(object)->read_property(object, &property, silent?BP_VAR_IS:BP_VAR_R, NULL, &rv);
+ value = Z_OBJ_HT_P(object)->read_property(object, &property, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
zval_ptr_dtor(&property);
EG(scope) = old_scope;
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(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent);
+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_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
void zend_exception_set_previous(zend_object *exception, zend_object *add_previous)
{
- zval tmp, *previous, zv, *pzv;
+ zval tmp, *previous, zv, *pzv, rv;
if (exception == add_previous || !add_previous || !exception) {
return;
ZVAL_OBJ(&zv, exception);
pzv = &zv;
do {
- previous = zend_read_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, 1);
+ previous = zend_read_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, 1, &rv);
if (Z_TYPE_P(previous) == IS_NULL) {
zend_update_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, &tmp);
GC_REFCOUNT(add_previous)--;
}
#define GET_PROPERTY(object, name) \
- zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 0)
+ zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 0, &rv)
#define GET_PROPERTY_SILENT(object, name) \
- zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 1)
+ zend_read_property(default_exception_ce, (object), name, sizeof(name) - 1, 1, &rv)
/* {{{ proto string Exception::getFile()
Get the file in which the exception occurred */
ZEND_METHOD(exception, getFile)
{
+ zval rv;
+
DEFAULT_0_PARAMS;
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), "file"));
Get the line in which the exception occurred */
ZEND_METHOD(exception, getLine)
{
+ zval rv;
+
DEFAULT_0_PARAMS;
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), "line"));
Get the exception message */
ZEND_METHOD(exception, getMessage)
{
+ zval rv;
+
DEFAULT_0_PARAMS;
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), "message"));
Get the exception code */
ZEND_METHOD(exception, getCode)
{
+ zval rv;
+
DEFAULT_0_PARAMS;
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), "code"));
Get the stack trace for the location in which the exception occurred */
ZEND_METHOD(exception, getTrace)
{
+ zval rv;
+
DEFAULT_0_PARAMS;
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), "trace"));
Get the exception severity */
ZEND_METHOD(error_exception, getSeverity)
{
+ zval rv;
+
DEFAULT_0_PARAMS;
ZVAL_COPY(return_value, GET_PROPERTY(getThis(), "severity"));
Obtain the backtrace for the exception as a string (instead of an array) */
ZEND_METHOD(exception, getTraceAsString)
{
- zval *trace, *frame;
+ zval *trace, *frame, rv;
zend_ulong index;
smart_str str = {0};
uint32_t num = 0;
DEFAULT_0_PARAMS;
- trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1);
+ trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1, &rv);
ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(trace), index, frame) {
if (Z_TYPE_P(frame) != IS_ARRAY) {
zend_error(E_WARNING, "Expected array for frame %pu", index);
Return previous Exception or NULL. */
ZEND_METHOD(exception, getPrevious)
{
+ zval rv;
+
DEFAULT_0_PARAMS;
ZVAL_COPY(return_value, GET_PROPERTY_SILENT(getThis(), "previous"));
zval trace, *exception;
zend_string *str;
zend_fcall_info fci;
- zval fname;
+ zval fname, rv;
DEFAULT_0_PARAMS;
ZVAL_OBJ(&exception, ex);
ce_exception = Z_OBJCE(exception);
if (instanceof_function(ce_exception, default_exception_ce)) {
- zval tmp;
+ zval tmp, rv;
zend_string *str, *file = NULL;
zend_long line = 0;
* 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);
+ retval = zend_read_property(Z_OBJCE(disp->object), &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), ¶ms[0]);
} else if (wFlags & DISPATCH_METHOD) {
static void curlfile_get_property(char *name, INTERNAL_FUNCTION_PARAMETERS)
{
- zval *res;
+ zval *res, rv;
+
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- res = zend_read_property(curl_CURLFile_class, getThis(), name, strlen(name), 1);
+ res = zend_read_property(curl_CURLFile_class, getThis(), name, strlen(name), 1, &rv);
RETURN_ZVAL(res, 1, 0);
}
if (Z_TYPE_P(current) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(current), curl_CURLFile_class)) {
/* new-style file upload */
- zval *prop;
+ zval *prop, rv;
char *type = NULL, *filename = NULL;
- prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0);
+ prop = zend_read_property(curl_CURLFile_class, 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", string_key->val);
} else {
return 1;
}
- prop = zend_read_property(curl_CURLFile_class, current, "mime", sizeof("mime")-1, 0);
+ prop = zend_read_property(curl_CURLFile_class, 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);
+ prop = zend_read_property(curl_CURLFile_class, current, "postname", sizeof("postname")-1, 0, &rv);
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
filename = Z_STRVAL_P(prop);
}
int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty)
{
zend_long offset = zval_get_long(member);
+ zval rv;
if (offset < 0) {
return 0;
} else {
- zval *length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0);
+ zval *length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0, &rv);
return length && offset < Z_LVAL_P(length);
}
} else {
const char *class_name, *prop_name;
size_t prop_name_len;
+ zval rv;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &object) == FAILURE) {
return;
}
zend_unmangle_property_name_ex(ref->prop.name, &class_name, &prop_name, &prop_name_len);
- member_p = zend_read_property(ref->ce, object, prop_name, prop_name_len, 1);
+ member_p = zend_read_property(ref->ce, object, prop_name, prop_name_len, 1, &rv);
ZVAL_DUP(return_value, member_p);
}
}
SoapFault constructor */
PHP_METHOD(SoapFault, __toString)
{
- zval *faultcode, *faultstring, *file, *line, trace;
+ zval *faultcode, *faultstring, *file, *line, trace, rv1, rv2, rv3, rv4;
zend_string *str;
zend_fcall_info fci;
zval *this_ptr;
}
this_ptr = getThis();
- faultcode = zend_read_property(soap_fault_class_entry, this_ptr, "faultcode", sizeof("faultcode")-1, 1);
- faultstring = zend_read_property(soap_fault_class_entry, this_ptr, "faultstring", sizeof("faultstring")-1, 1);
- file = zend_read_property(soap_fault_class_entry, this_ptr, "file", sizeof("file")-1, 1);
- line = zend_read_property(soap_fault_class_entry, this_ptr, "line", sizeof("line")-1, 1);
+ 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);
fci.size = sizeof(fci);
fci.function_table = &Z_OBJCE_P(getThis())->function_table;
char *subject;
zend_string *result;
int subject_len, use_copy, count = 0;
- zval *subject_ptr, subject_copy, zcount, *replacement, tmp_replacement;
+ zval *subject_ptr, subject_copy, zcount, *replacement, tmp_replacement, rv;
if (zend_parse_parameters_none() == FAILURE) {
return;
break;
case REGIT_MODE_REPLACE:
- replacement = zend_read_property(intern->std.ce, getThis(), "replacement", sizeof("replacement")-1, 1);
+ replacement = zend_read_property(intern->std.ce, getThis(), "replacement", sizeof("replacement")-1, 1, &rv);
if (Z_TYPE_P(replacement) != IS_STRING) {
tmp_replacement = *replacement;
zval_copy_ctor(&tmp_replacement);
zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg);
if (EG(exception)) {
- zval tmp, *msg;
+ zval tmp, *msg, rv;
ZVAL_OBJ(&tmp, EG(exception));
- msg = zend_read_property(zend_exception_get_default(), &tmp, "message", sizeof("message")-1, 0);
+ msg = zend_read_property(zend_exception_get_default(), &tmp, "message", sizeof("message")-1, 0, &rv);
zend_printf("Exception: %s\n", Z_STRVAL_P(msg));
zval_ptr_dtor(&tmp);
EG(exception) = NULL;