|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patch jsonserializedepth for JSON related Bug #72073Patch version 2016-04-22 16:48 UTC Return to Bug #72073 | Download this patchThis patch is obsolete Obsoleted by patches: Patch Revisions:
Developer: jani.ollikainen@valve.fi
diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c
index c3aa348..b3f3310 100644
--- a/ext/json/json_encoder.c
+++ b/ext/json/json_encoder.c
@@ -446,7 +446,7 @@ static void php_json_escape_string(smart_str *buf, char *s, size_t len, int opti
static void php_json_encode_serializable_object(smart_str *buf, zval *val, int options) /* {{{ */
{
zend_class_entry *ce = Z_OBJCE_P(val);
- zval retval, fname;
+ zval retval, fname, args[1];
HashTable* myht;
if (Z_TYPE_P(val) == IS_ARRAY) {
@@ -461,17 +461,21 @@ static void php_json_encode_serializable_object(smart_str *buf, zval *val, int o
return;
}
+ ZVAL_LONG(&args[0], JSON_G(encoder_depth));
ZVAL_STRING(&fname, "jsonSerialize");
- if (FAILURE == call_user_function_ex(EG(function_table), val, &fname, &retval, 0, NULL, 1, NULL) || Z_TYPE(retval) == IS_UNDEF) {
+
+ if (FAILURE == call_user_function_ex(EG(function_table), val, &fname, &retval, 1, args, 1, NULL) || Z_TYPE(retval) == IS_UNDEF) {
zend_throw_exception_ex(NULL, 0, "Failed calling %s::jsonSerialize()", ZSTR_VAL(ce->name));
smart_str_appendl(buf, "null", sizeof("null") - 1);
+ zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&fname);
return;
}
if (EG(exception)) {
/* Error already raised */
+ zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&fname);
smart_str_appendl(buf, "null", sizeof("null") - 1);
@@ -487,6 +491,7 @@ static void php_json_encode_serializable_object(smart_str *buf, zval *val, int o
php_json_encode(buf, &retval, options);
}
+ zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&fname);
}
|
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |