mirror of
https://github.com/php/php-src.git
synced 2024-11-26 11:23:47 +08:00
(php_wddx_deserialize_ex) return SUCCESS/FAILURE
Use that return value in WDDX session deserializer.
This commit is contained in:
parent
a4a4de55f7
commit
1868bfdcdf
@ -336,42 +336,35 @@ PS_SERIALIZER_DECODE_FUNC(wddx)
|
||||
ulong idx;
|
||||
int hash_type;
|
||||
int dofree = 1;
|
||||
int ret = SUCCESS;
|
||||
int ret;
|
||||
|
||||
if (vallen == 0)
|
||||
return SUCCESS;
|
||||
|
||||
MAKE_STD_ZVAL(retval);
|
||||
|
||||
retval->type = IS_NULL;
|
||||
if ((ret = php_wddx_deserialize_ex((char *)val, vallen, retval)) == SUCCESS) {
|
||||
|
||||
php_wddx_deserialize_ex((char *)val, vallen, retval);
|
||||
for (zend_hash_internal_pointer_reset(retval->value.ht);
|
||||
zend_hash_get_current_data(retval->value.ht, (void **) &ent) == SUCCESS;
|
||||
zend_hash_move_forward(retval->value.ht)) {
|
||||
hash_type = zend_hash_get_current_key(retval->value.ht, &key, &idx);
|
||||
|
||||
if (retval->type == IS_NULL) {
|
||||
ret = FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (zend_hash_internal_pointer_reset(retval->value.ht);
|
||||
zend_hash_get_current_data(retval->value.ht, (void **) &ent) == SUCCESS;
|
||||
zend_hash_move_forward(retval->value.ht)) {
|
||||
hash_type = zend_hash_get_current_key(retval->value.ht, &key, &idx);
|
||||
|
||||
switch (hash_type) {
|
||||
case HASH_KEY_IS_LONG:
|
||||
sprintf(tmp, "%ld", idx);
|
||||
key = tmp;
|
||||
dofree = 0;
|
||||
/* fallthru */
|
||||
case HASH_KEY_IS_STRING:
|
||||
php_set_session_var(key, strlen(key), *ent PSLS_CC);
|
||||
PS_ADD_VAR(key);
|
||||
if (dofree) efree(key);
|
||||
dofree = 1;
|
||||
switch (hash_type) {
|
||||
case HASH_KEY_IS_LONG:
|
||||
sprintf(tmp, "%ld", idx);
|
||||
key = tmp;
|
||||
dofree = 0;
|
||||
/* fallthru */
|
||||
case HASH_KEY_IS_STRING:
|
||||
php_set_session_var(key, strlen(key), *ent PSLS_CC);
|
||||
PS_ADD_VAR(key);
|
||||
if (dofree) efree(key);
|
||||
dofree = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
zval_dtor(retval);
|
||||
efree(retval);
|
||||
|
||||
|
@ -60,7 +60,7 @@ void php_wddx_packet_end(wddx_packet *packet);
|
||||
|
||||
void php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name);
|
||||
void php_wddx_add_chunk_ex(wddx_packet *packet, char *str, int length);
|
||||
void php_wddx_deserialize_ex(char *, int, zval *return_value);
|
||||
int php_wddx_deserialize_ex(char *, int, zval *return_value);
|
||||
char *php_wddx_gather(wddx_packet *packet);
|
||||
|
||||
#endif /* PHP_WDDX_API_H */
|
||||
|
@ -744,12 +744,13 @@ static void php_wddx_process_data(void *user_data, const char *s, int len)
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ void php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) */
|
||||
void php_wddx_deserialize_ex(char *value, int vallen, zval *return_value)
|
||||
/* {{{ int php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) */
|
||||
int php_wddx_deserialize_ex(char *value, int vallen, zval *return_value)
|
||||
{
|
||||
wddx_stack stack;
|
||||
XML_Parser parser;
|
||||
st_entry *ent;
|
||||
int retval;
|
||||
|
||||
wddx_stack_init(&stack);
|
||||
parser = XML_ParserCreate("ISO-8859-1");
|
||||
@ -766,9 +767,13 @@ void php_wddx_deserialize_ex(char *value, int vallen, zval *return_value)
|
||||
wddx_stack_top(&stack, (void**)&ent);
|
||||
*return_value = *(ent->data);
|
||||
zval_copy_ctor(return_value);
|
||||
}
|
||||
retval = SUCCESS;
|
||||
} else
|
||||
retval = FAILURE;
|
||||
|
||||
wddx_stack_destroy(&stack);
|
||||
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user