diff options
author | Felipe Pena <felipensp@gmail.com> | 2012-05-08 21:05:51 -0300 |
---|---|---|
committer | Felipe Pena <felipensp@gmail.com> | 2012-05-08 21:05:51 -0300 |
commit | 92bc49b2b06417f86dc0fc537326e60f4d0a0c0b (patch) | |
tree | 570b7211d80f3ed83bc1938b4daf458837215363 /ext/json/json.c | |
parent | 2cb0ed1328da3bca00990648c3dfc90c957395f1 (diff) | |
download | php-git-92bc49b2b06417f86dc0fc537326e60f4d0a0c0b.tar.gz |
- Fixed bug #61978 (Object recursion not detected for classes that implement JsonSerializable)
Diffstat (limited to 'ext/json/json.c')
-rw-r--r-- | ext/json/json.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/json/json.c b/ext/json/json.c index fc1fcb7f1f..557fbc3e0c 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); |