Index: ext/xmlrpc/xmlrpc-epi-php.c =================================================================== RCS file: /repository/php-src/ext/xmlrpc/xmlrpc-epi-php.c,v retrieving revision 1.38 diff -u -p -d -r1.38 xmlrpc-epi-php.c --- ext/xmlrpc/xmlrpc-epi-php.c 30 Jun 2005 22:29:33 -0000 1.38 +++ ext/xmlrpc/xmlrpc-epi-php.c 8 Jul 2005 20:41:32 -0000 @@ -481,6 +481,8 @@ static XMLRPC_VECTOR_TYPE determine_vect static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int depth) { XMLRPC_VALUE xReturn = NULL; + TSRMLS_FETCH(); + if(in_val) { zval* val = NULL; XMLRPC_VALUE_TYPE type = get_zval_xmlrpc_type(in_val, &val); @@ -528,9 +530,27 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker zend_hash_internal_pointer_reset(Z_ARRVAL_P(val)); while(1) { int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val), &my_key, &num_index); + HashTable *ht = NULL; + if(res == HASH_KEY_IS_LONG) { if(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) { - XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(0, *pIter, depth++)); + if (Z_TYPE_PP(pIter) == IS_ARRAY) { + ht = Z_ARRVAL_PP(pIter); + } + if (Z_TYPE_PP(pIter) == IS_OBJECT) { + ht = Z_OBJPROP_PP(pIter); + } + if (ht && ht->nApplyCount > 1) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "XML-RPC doesn't support circular references"); + return NULL; + } + if (ht) { + ht->nApplyCount++; + } + XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(0, *pIter, depth++)); + if (ht) { + ht->nApplyCount--; + } } } else if(res == HASH_KEY_NON_EXISTANT) { @@ -538,7 +558,23 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker } else if(res == HASH_KEY_IS_STRING) { if(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) { - XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(my_key, *pIter, depth++)); + if (Z_TYPE_PP(pIter) == IS_ARRAY) { + ht = Z_ARRVAL_PP(pIter); + } + if (Z_TYPE_PP(pIter) == IS_OBJECT) { + ht = Z_OBJPROP_PP(pIter); + } + if (ht && ht->nApplyCount > 1) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "XML-RPC doesn't support circular references"); + return NULL; + } + if (ht) { + ht->nApplyCount++; + } + XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(my_key, *pIter, depth++)); + if (ht) { + ht->nApplyCount--; + } } }