version 1.1.1.1, 2012/02/21 23:48:02
|
version 1.1.1.2, 2012/05/29 12:34:43
|
Line 33 typedef struct {
|
Line 33 typedef struct {
|
|
|
static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval) |
static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval) |
{ |
{ |
var_entries *var_hash = var_hashx->first, *prev = NULL; | var_entries *var_hash = (*var_hashx)->last; |
| #if 0 |
| fprintf(stderr, "var_push(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval)); |
| #endif |
|
|
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) { | if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { |
prev = var_hash; | |
var_hash = var_hash->next; | |
} | |
| |
if (!var_hash) { | |
var_hash = emalloc(sizeof(var_entries)); |
var_hash = emalloc(sizeof(var_entries)); |
var_hash->used_slots = 0; |
var_hash->used_slots = 0; |
var_hash->next = 0; |
var_hash->next = 0; |
|
|
if (!var_hashx->first) | if (!(*var_hashx)->first) { |
var_hashx->first = var_hash; | (*var_hashx)->first = var_hash; |
else | } else { |
prev->next = var_hash; | ((var_entries *) (*var_hashx)->last)->next = var_hash; |
| } |
| |
| (*var_hashx)->last = var_hash; |
} |
} |
|
|
var_hash->data[var_hash->used_slots++] = *rval; |
var_hash->data[var_hash->used_slots++] = *rval; |
Line 56 static inline void var_push(php_unserialize_data_t *va
|
Line 57 static inline void var_push(php_unserialize_data_t *va
|
|
|
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval) |
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval) |
{ |
{ |
var_entries *var_hash = var_hashx->first_dtor, *prev = NULL; | var_entries *var_hash = (*var_hashx)->last_dtor; |
| #if 0 |
| fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval)); |
| #endif |
|
|
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) { | if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { |
prev = var_hash; | |
var_hash = var_hash->next; | |
} | |
| |
if (!var_hash) { | |
var_hash = emalloc(sizeof(var_entries)); |
var_hash = emalloc(sizeof(var_entries)); |
var_hash->used_slots = 0; |
var_hash->used_slots = 0; |
var_hash->next = 0; |
var_hash->next = 0; |
|
|
if (!var_hashx->first_dtor) | if (!(*var_hashx)->first_dtor) { |
var_hashx->first_dtor = var_hash; | (*var_hashx)->first_dtor = var_hash; |
else | } else { |
prev->next = var_hash; | ((var_entries *) (*var_hashx)->last_dtor)->next = var_hash; |
| } |
| |
| (*var_hashx)->last_dtor = var_hash; |
} |
} |
|
|
Z_ADDREF_PP(rval); |
Z_ADDREF_PP(rval); |
Line 81 PHPAPI void var_push_dtor(php_unserialize_data_t *var_
|
Line 83 PHPAPI void var_push_dtor(php_unserialize_data_t *var_
|
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval) |
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval) |
{ |
{ |
long i; |
long i; |
var_entries *var_hash = var_hashx->first; | var_entries *var_hash = (*var_hashx)->first; |
| #if 0 |
| fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(nzval)); |
| #endif |
|
|
while (var_hash) { |
while (var_hash) { |
for (i = 0; i < var_hash->used_slots; i++) { |
for (i = 0; i < var_hash->used_slots; i++) { |
Line 96 PHPAPI void var_replace(php_unserialize_data_t *var_ha
|
Line 101 PHPAPI void var_replace(php_unserialize_data_t *var_ha
|
|
|
static int var_access(php_unserialize_data_t *var_hashx, long id, zval ***store) |
static int var_access(php_unserialize_data_t *var_hashx, long id, zval ***store) |
{ |
{ |
var_entries *var_hash = var_hashx->first; | var_entries *var_hash = (*var_hashx)->first; |
| #if 0 |
| fprintf(stderr, "var_access(%ld): %ld\n", var_hash?var_hash->used_slots:-1L, id); |
| #endif |
| |
while (id >= VAR_ENTRIES_MAX && var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) { |
while (id >= VAR_ENTRIES_MAX && var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) { |
var_hash = var_hash->next; |
var_hash = var_hash->next; |
id -= VAR_ENTRIES_MAX; |
id -= VAR_ENTRIES_MAX; |
Line 116 PHPAPI void var_destroy(php_unserialize_data_t *var_ha
|
Line 124 PHPAPI void var_destroy(php_unserialize_data_t *var_ha
|
{ |
{ |
void *next; |
void *next; |
long i; |
long i; |
var_entries *var_hash = var_hashx->first; | var_entries *var_hash = (*var_hashx)->first; |
| #if 0 |
| fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L); |
| #endif |
|
|
while (var_hash) { |
while (var_hash) { |
next = var_hash->next; |
next = var_hash->next; |
Line 124 PHPAPI void var_destroy(php_unserialize_data_t *var_ha
|
Line 135 PHPAPI void var_destroy(php_unserialize_data_t *var_ha
|
var_hash = next; |
var_hash = next; |
} |
} |
|
|
var_hash = var_hashx->first_dtor; | var_hash = (*var_hashx)->first_dtor; |
|
|
while (var_hash) { |
while (var_hash) { |
for (i = 0; i < var_hash->used_slots; i++) { |
for (i = 0; i < var_hash->used_slots; i++) { |
Line 368 static inline long object_common1(UNSERIALIZE_PARAMETE
|
Line 379 static inline long object_common1(UNSERIALIZE_PARAMETE
|
return elements; |
return elements; |
} |
} |
|
|
|
#ifdef PHP_WIN32 |
|
# pragma optimize("", off) |
|
#endif |
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) |
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) |
{ |
{ |
zval *retval_ptr = NULL; |
zval *retval_ptr = NULL; |
Line 381 static inline int object_common2(UNSERIALIZE_PARAMETER
|
Line 395 static inline int object_common2(UNSERIALIZE_PARAMETER
|
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) { |
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) { |
INIT_PZVAL(&fname); |
INIT_PZVAL(&fname); |
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0); |
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0); |
|
BG(serialize_lock)++; |
call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); |
call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); |
|
BG(serialize_lock)--; |
} |
} |
|
|
if (retval_ptr) |
if (retval_ptr) |
Line 390 static inline int object_common2(UNSERIALIZE_PARAMETER
|
Line 406 static inline int object_common2(UNSERIALIZE_PARAMETER
|
return finish_nested_data(UNSERIALIZE_PASSTHRU); |
return finish_nested_data(UNSERIALIZE_PASSTHRU); |
|
|
} |
} |
|
#ifdef PHP_WIN32 |
|
# pragma optimize("", on) |
|
#endif |
|
|
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) |
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) |
{ |
{ |
const unsigned char *cursor, *limit, *marker, *start; |
const unsigned char *cursor, *limit, *marker, *start; |
zval **rval_ref; |
zval **rval_ref; |
|
|
limit = cursor = *p; | limit = max; |
| cursor = *p; |
| |
| if (YYCURSOR >= YYLIMIT) { |
| return 0; |
| } |
|
|
if (var_hash && cursor[0] != 'R') { |
if (var_hash && cursor[0] != 'R') { |
var_push(var_hash, rval); |
var_push(var_hash, rval); |