diff options
author | Felipe Pena <felipe@php.net> | 2009-11-24 11:32:31 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2009-11-24 11:32:31 +0000 |
commit | 2e35533fc67456b5542977aecf325dc06c9d69d7 (patch) | |
tree | fef1d41430252d7638f1ff63ed70c9e7d2f570cb /ext/xmlrpc | |
parent | ebc1b9f13d9bcabb335ea9002d9b470ba39e112d (diff) | |
download | php-git-2e35533fc67456b5542977aecf325dc06c9d69d7.tar.gz |
- Fixed bug #50282 (xmlrpc_encode_request() changes object into array in calling function)
Diffstat (limited to 'ext/xmlrpc')
-rw-r--r-- | ext/xmlrpc/tests/bug50282.phpt | 43 | ||||
-rw-r--r-- | ext/xmlrpc/xmlrpc-epi-php.c | 21 |
2 files changed, 57 insertions, 7 deletions
diff --git a/ext/xmlrpc/tests/bug50282.phpt b/ext/xmlrpc/tests/bug50282.phpt new file mode 100644 index 0000000000..eb35fe3f2d --- /dev/null +++ b/ext/xmlrpc/tests/bug50282.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #50282 (xmlrpc_encode_request() changes object into array in calling function) +--SKIPIF-- +<?php if (!extension_loaded("xmlrpc")) print "skip"; ?> +--FILE-- +<?php + +class One { var $x = 10; } + +$o = new One(); +var_dump($o); +var_dump(xmlrpc_encode_request('test', $o)); +var_dump($o); + +?> +--EXPECTF-- +object(One)#%d (1) { + ["x"]=> + int(10) +} +string(279) "<?xml version="1.0" encoding="iso-8859-1"?> +<methodCall> +<methodName>test</methodName> +<params> + <param> + <value> + <struct> + <member> + <name>x</name> + <value> + <int>10</int> + </value> + </member> + </struct> + </value> + </param> +</params> +</methodCall> +" +object(One)#%d (1) { + ["x"]=> + int(10) +} diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index 533b06aaee..df63759dcb 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -556,6 +556,7 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep zval** pIter; char* my_key; HashTable *ht = NULL; + zval *val_arr; ht = HASH_OF(val); if (ht && ht->nApplyCount > 1) { @@ -563,12 +564,17 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep return NULL; } - convert_to_array(val); - xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val))); + MAKE_STD_ZVAL(val_arr); + *val_arr = *val; + zval_copy_ctor(val_arr); + INIT_PZVAL(val_arr); + convert_to_array(val_arr); + + xReturn = XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val_arr))); - zend_hash_internal_pointer_reset(Z_ARRVAL_P(val)); - while(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) { - int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val), &my_key, &num_index); + zend_hash_internal_pointer_reset(Z_ARRVAL_P(val_arr)); + while(zend_hash_get_current_data(Z_ARRVAL_P(val_arr), (void**)&pIter) == SUCCESS) { + int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val_arr), &my_key, &num_index); switch (res) { case HASH_KEY_NON_EXISTANT: @@ -589,8 +595,9 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep } break; } - zend_hash_move_forward(Z_ARRVAL_P(val)); - } + zend_hash_move_forward(Z_ARRVAL_P(val_arr)); + } + zval_ptr_dtor(&val_arr); } break; default: |