@@ -498,7 +498,6 @@ static void php_session_gc(void) /* {{{ */
498
498
}
499
499
} /* }}} */
500
500
501
-
502
501
static void php_session_initialize (void ) /* {{{ */
503
502
{
504
503
zend_string * val = NULL ;
@@ -613,6 +612,22 @@ static void php_session_save_current_state(int write) /* {{{ */
613
612
}
614
613
/* }}} */
615
614
615
+ static void php_session_normalize_vars () /* {{{ */
616
+ {
617
+ PS_ENCODE_VARS ;
618
+
619
+ IF_SESSION_VARS () {
620
+ PS_ENCODE_LOOP (
621
+ if (Z_TYPE_P (struc ) == IS_PTR ) {
622
+ zval * zv = (zval * )Z_PTR_P (struc );
623
+ ZVAL_COPY_VALUE (struc , zv );
624
+ ZVAL_UNDEF (zv );
625
+ }
626
+ );
627
+ }
628
+ }
629
+ /* }}} */
630
+
616
631
/* *************************
617
632
* INI Settings/Handlers *
618
633
************************* */
@@ -944,7 +959,6 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
944
959
{
945
960
const char * p ;
946
961
const char * endptr = val + vallen ;
947
- zval current ;
948
962
int has_value ;
949
963
int namelen ;
950
964
zend_string * name ;
@@ -967,28 +981,32 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
967
981
p += namelen + 1 ;
968
982
969
983
if ((tmp = zend_hash_find (& EG (symbol_table ), name ))) {
970
- if ((Z_TYPE_P (tmp ) == IS_ARRAY && Z_ARRVAL_P (tmp ) == & EG (symbol_table )) || tmp == & PS (http_session_vars )) {
984
+ if ((Z_TYPE_P (tmp ) == IS_ARRAY &&
985
+ Z_ARRVAL_P (tmp ) == & EG (symbol_table )) || tmp == & PS (http_session_vars )) {
971
986
zend_string_release (name );
972
987
continue ;
973
988
}
974
989
}
975
990
976
991
if (has_value ) {
977
- ZVAL_UNDEF (& current );
978
- if (php_var_unserialize (& current , (const unsigned char * * ) & p , (const unsigned char * ) endptr , & var_hash )) {
979
- zval * zv = php_set_session_var (name , & current , & var_hash );
980
- var_replace (& var_hash , & current , zv );
992
+ zval * current , rv ;
993
+ current = var_tmp_var (& var_hash );
994
+ if (php_var_unserialize (current , (const unsigned char * * ) & p , (const unsigned char * ) endptr , & var_hash )) {
995
+ ZVAL_PTR (& rv , current );
996
+ php_set_session_var (name , & rv , & var_hash );
981
997
} else {
982
- zval_ptr_dtor (& current );
983
998
zend_string_release (name );
999
+ php_session_normalize_vars ();
984
1000
PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
985
1001
return FAILURE ;
986
1002
}
1003
+ } else {
1004
+ PS_ADD_VARL (name );
987
1005
}
988
- PS_ADD_VARL (name );
989
1006
zend_string_release (name );
990
1007
}
991
1008
1009
+ php_session_normalize_vars ();
992
1010
PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
993
1011
994
1012
return SUCCESS ;
@@ -1033,10 +1051,9 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
1033
1051
{
1034
1052
const char * p , * q ;
1035
1053
const char * endptr = val + vallen ;
1036
- zval current ;
1037
- int has_value ;
1038
1054
ptrdiff_t namelen ;
1039
1055
zend_string * name ;
1056
+ int has_value , retval = SUCCESS ;
1040
1057
php_unserialize_data_t var_hash ;
1041
1058
1042
1059
PHP_VAR_UNSERIALIZE_INIT (var_hash );
@@ -1061,34 +1078,37 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
1061
1078
q ++ ;
1062
1079
1063
1080
if ((tmp = zend_hash_find (& EG (symbol_table ), name ))) {
1064
- if ((Z_TYPE_P (tmp ) == IS_ARRAY && Z_ARRVAL_P (tmp ) == & EG (symbol_table )) || tmp == & PS (http_session_vars )) {
1081
+ if ((Z_TYPE_P (tmp ) == IS_ARRAY &&
1082
+ Z_ARRVAL_P (tmp ) == & EG (symbol_table )) || tmp == & PS (http_session_vars )) {
1065
1083
goto skip ;
1066
1084
}
1067
1085
}
1068
1086
1069
1087
if (has_value ) {
1070
- ZVAL_UNDEF (& current );
1071
- if (php_var_unserialize (& current , (const unsigned char * * ) & q , (const unsigned char * ) endptr , & var_hash )) {
1072
- zval * zv = php_set_session_var (name , & current , & var_hash );
1073
- var_replace (& var_hash , & current , zv );
1088
+ zval * current , rv ;
1089
+ current = var_tmp_var (& var_hash );
1090
+ if (php_var_unserialize (current , (const unsigned char * * )& q , (const unsigned char * )endptr , & var_hash )) {
1091
+ ZVAL_PTR (& rv , current );
1092
+ php_set_session_var (name , & rv , & var_hash );
1074
1093
} else {
1075
- zval_ptr_dtor (& current );
1076
- PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
1077
1094
zend_string_release (name );
1078
- return FAILURE ;
1095
+ retval = FAILURE ;
1096
+ goto break_outer_loop ;
1079
1097
}
1098
+ } else {
1099
+ PS_ADD_VARL (name );
1080
1100
}
1081
- PS_ADD_VARL (name );
1082
1101
skip :
1083
1102
zend_string_release (name );
1084
1103
1085
1104
p = q ;
1086
1105
}
1087
1106
break_outer_loop :
1107
+ php_session_normalize_vars ();
1088
1108
1089
1109
PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
1090
1110
1091
- return SUCCESS ;
1111
+ return retval ;
1092
1112
}
1093
1113
/* }}} */
1094
1114
0 commit comments