From 176dfdb4c37e2e6ce7ae635e1d47afa9f49b3369 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Sat, 2 Nov 2013 11:57:14 +0200 Subject: [PATCH] Fix #1504 --- ext/config.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ext/config.c b/ext/config.c index d5038450b13..8c39631bdd0 100644 --- a/ext/config.c +++ b/ext/config.c @@ -151,10 +151,19 @@ static void phalcon_config_write_internal(phalcon_config_object *object, zval *o { if (Z_TYPE_P(value) == IS_ARRAY) { zval *instance; - MAKE_STD_ZVAL(instance); - object_init_ex(instance, phalcon_config_ce); - phalcon_config_construct_internal(instance, value TSRMLS_CC); - phalcon_hash_update_or_insert(object->props, offset, instance); + HashTable *h = Z_ARRVAL_P(value); + + if (!h->nApplyCount) { + ++h->nApplyCount; + MAKE_STD_ZVAL(instance); + object_init_ex(instance, phalcon_config_ce); + phalcon_config_construct_internal(instance, value TSRMLS_CC); + phalcon_hash_update_or_insert(object->props, offset, instance); + --h->nApplyCount; + } + else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Recursion detected"); + } } else { Z_ADDREF_P(value);