}
} /* }}} */
-
static void php_session_initialize(void) /* {{{ */
{
zend_string *val = NULL;
}
/* }}} */
+static void php_session_normalize_vars() /* {{{ */
+{
+ PS_ENCODE_VARS;
+
+ IF_SESSION_VARS() {
+ PS_ENCODE_LOOP(
+ if (Z_TYPE_P(struc) == IS_PTR) {
+ zval *zv = (zval *)Z_PTR_P(struc);
+ ZVAL_COPY_VALUE(struc, zv);
+ ZVAL_UNDEF(zv);
+ }
+ );
+ }
+}
+/* }}} */
+
/* *************************
* INI Settings/Handlers *
************************* */
{
const char *p;
const char *endptr = val + vallen;
- zval current;
int has_value;
int namelen;
zend_string *name;
p += namelen + 1;
if ((tmp = zend_hash_find(&EG(symbol_table), name))) {
- if ((Z_TYPE_P(tmp) == IS_ARRAY && Z_ARRVAL_P(tmp) == &EG(symbol_table)) || tmp == &PS(http_session_vars)) {
+ if ((Z_TYPE_P(tmp) == IS_ARRAY &&
+ Z_ARRVAL_P(tmp) == &EG(symbol_table)) || tmp == &PS(http_session_vars)) {
zend_string_release(name);
continue;
}
}
if (has_value) {
- ZVAL_UNDEF(¤t);
- if (php_var_unserialize(¤t, (const unsigned char **) &p, (const unsigned char *) endptr, &var_hash)) {
- zval *zv = php_set_session_var(name, ¤t, &var_hash );
- var_replace(&var_hash, ¤t, zv);
+ zval *current, rv;
+ current = var_tmp_var(&var_hash);
+ if (php_var_unserialize(current, (const unsigned char **) &p, (const unsigned char *) endptr, &var_hash)) {
+ ZVAL_PTR(&rv, current);
+ php_set_session_var(name, &rv, &var_hash );
} else {
- zval_ptr_dtor(¤t);
zend_string_release(name);
+ php_session_normalize_vars();
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return FAILURE;
}
+ } else {
+ PS_ADD_VARL(name);
}
- PS_ADD_VARL(name);
zend_string_release(name);
}
+ php_session_normalize_vars();
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return SUCCESS;
{
const char *p, *q;
const char *endptr = val + vallen;
- zval current;
- int has_value;
ptrdiff_t namelen;
zend_string *name;
+ int has_value, retval = SUCCESS;
php_unserialize_data_t var_hash;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
q++;
if ((tmp = zend_hash_find(&EG(symbol_table), name))) {
- if ((Z_TYPE_P(tmp) == IS_ARRAY && Z_ARRVAL_P(tmp) == &EG(symbol_table)) || tmp == &PS(http_session_vars)) {
+ if ((Z_TYPE_P(tmp) == IS_ARRAY &&
+ Z_ARRVAL_P(tmp) == &EG(symbol_table)) || tmp == &PS(http_session_vars)) {
goto skip;
}
}
if (has_value) {
- ZVAL_UNDEF(¤t);
- if (php_var_unserialize(¤t, (const unsigned char **) &q, (const unsigned char *) endptr, &var_hash)) {
- zval *zv = php_set_session_var(name, ¤t, &var_hash);
- var_replace(&var_hash, ¤t, zv);
+ zval *current, rv;
+ current = var_tmp_var(&var_hash);
+ if (php_var_unserialize(current, (const unsigned char **)&q, (const unsigned char *)endptr, &var_hash)) {
+ ZVAL_PTR(&rv, current);
+ php_set_session_var(name, &rv, &var_hash);
} else {
- zval_ptr_dtor(¤t);
- PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
zend_string_release(name);
- return FAILURE;
+ retval = FAILURE;
+ goto break_outer_loop;
}
+ } else {
+ PS_ADD_VARL(name);
}
- PS_ADD_VARL(name);
skip:
zend_string_release(name);
p = q;
}
break_outer_loop:
+ php_session_normalize_vars();
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
- return SUCCESS;
+ return retval;
}
/* }}} */