Skip to content

Commit 7f9723b

Browse files
committed
Fixing tests (6 memleaks left)
1 parent ab5116e commit 7f9723b

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

msgpack.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -134,53 +134,54 @@ ZEND_GET_MODULE(msgpack)
134134
#if HAVE_PHP_SESSION
135135
PS_SERIALIZER_ENCODE_FUNC(msgpack) /* {{{ */
136136
{
137-
smart_str buf = {0};
138-
msgpack_serialize_data_t var_hash;
137+
smart_str buf = {0};
138+
msgpack_serialize_data_t var_hash;
139139

140-
msgpack_serialize_var_init(&var_hash);
140+
msgpack_serialize_var_init(&var_hash);
141141
msgpack_serialize_zval(&buf, &PS(http_session_vars), var_hash);
142-
msgpack_serialize_var_destroy(&var_hash);
142+
msgpack_serialize_var_destroy(&var_hash);
143143

144144
smart_str_0(&buf);
145145

146-
return buf.s;
146+
return buf.s;
147147
}
148148

149149
/* }}} */
150150

151151
PS_SERIALIZER_DECODE_FUNC(msgpack) /* {{{ */ {
152-
int ret;
153-
zend_string *key_str;
154-
zval tmp, *value;
155-
msgpack_unpack_t mp;
156-
msgpack_unserialize_data_t var_hash;
157-
size_t off = 0;
152+
int ret;
153+
zend_string *key_str;
154+
zval tmp, *value;
155+
msgpack_unpack_t mp;
156+
msgpack_unserialize_data_t var_hash;
157+
size_t off = 0;
158158

159-
template_init(&mp);
159+
template_init(&mp);
160160

161-
msgpack_unserialize_var_init(&var_hash);
161+
msgpack_unserialize_var_init(&var_hash);
162162

163-
mp.user.retval = &tmp;
164-
mp.user.var_hash = &var_hash;
163+
mp.user.retval = &tmp;
164+
mp.user.var_hash = &var_hash;
165165

166-
ret = template_execute(&mp, val, vallen, &off);
166+
ret = template_execute(&mp, val, vallen, &off);
167167

168-
if (ret == MSGPACK_UNPACK_EXTRA_BYTES || ret == MSGPACK_UNPACK_SUCCESS) {
169-
msgpack_unserialize_var_destroy(&var_hash, 0);
168+
if (ret == MSGPACK_UNPACK_EXTRA_BYTES || ret == MSGPACK_UNPACK_SUCCESS) {
169+
msgpack_unserialize_var_destroy(&var_hash, 0);
170170

171-
ZEND_HASH_FOREACH_STR_KEY_VAL(HASH_OF(&tmp), key_str, value) {
172-
if (key_str) {
173-
php_set_session_var(key_str, value, NULL);
174-
php_add_session_var(key_str);
175-
}
176-
} ZEND_HASH_FOREACH_END();
171+
ZEND_HASH_FOREACH_STR_KEY_VAL(HASH_OF(&tmp), key_str, value) {
172+
if (key_str) {
173+
php_set_session_var(key_str, value, NULL);
174+
php_add_session_var(key_str);
175+
ZVAL_UNDEF(value);
176+
}
177+
} ZEND_HASH_FOREACH_END();
177178

178-
zval_ptr_dtor(&tmp);
179-
} else {
180-
msgpack_unserialize_var_destroy(&var_hash, 1);
181-
}
179+
zval_ptr_dtor(&tmp);
180+
} else {
181+
msgpack_unserialize_var_destroy(&var_hash, 1);
182+
}
182183

183-
return SUCCESS;
184+
return SUCCESS;
184185
}
185186
/* }}} */
186187
#endif

0 commit comments

Comments
 (0)