summaryrefslogtreecommitdiff
path: root/ext/json/json.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-05-28 16:52:15 +0200
committerOndřej Surý <ondrej@sury.org>2012-05-28 16:52:15 +0200
commit01c525f668ecff08bea21c4ff22745b8f77e8c3a (patch)
tree07ebb675549d7a8ceb905676e4894151122321ac /ext/json/json.c
parentd4d61a2bcb9975c8aeddbc6603211064174087a9 (diff)
downloadphp-upstream/5.4.4_rc1.tar.gz
Imported Upstream version 5.4.4~rc1upstream/5.4.4_rc1
Diffstat (limited to 'ext/json/json.c')
-rw-r--r--ext/json/json.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/json/json.c b/ext/json/json.c
index fc1fcb7f1..557fbc3e0 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -513,6 +513,19 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio
{
zend_class_entry *ce = Z_OBJCE_P(val);
zval *retval = NULL, fname;
+ HashTable* myht;
+
+ if (Z_TYPE_P(val) == IS_ARRAY) {
+ myht = HASH_OF(val);
+ } else {
+ myht = Z_OBJPROP_P(val);
+ }
+
+ if (myht && myht->nApplyCount > 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
+ smart_str_appendl(buf, "null", 4);
+ return;
+ }
ZVAL_STRING(&fname, "jsonSerialize", 0);