mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ext/session: remove PS_ENCODE_VARS
By moving the declaration of the variables inside PS_ENCODE_LOOP() macro.
This commit is contained in:
@@ -285,26 +285,20 @@ PHPAPI zend_result php_session_reset_id(void);
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define PS_ENCODE_VARS \
|
||||
zend_string *key; \
|
||||
zend_ulong num_key; \
|
||||
zval *struc;
|
||||
|
||||
/* Do not use a return statement in `code` because that may leak memory.
|
||||
* Break out of the loop instead. */
|
||||
#define PS_ENCODE_LOOP(code) do { \
|
||||
zval _zv; \
|
||||
/* protect against user interference */ \
|
||||
ZVAL_COPY(&_zv, Z_REFVAL(PS(http_session_vars))); \
|
||||
HashTable *_ht = Z_ARRVAL(_zv); \
|
||||
ZEND_HASH_FOREACH_KEY(_ht, num_key, key) { \
|
||||
ZEND_HASH_FOREACH_KEY(Z_ARRVAL(_zv), zend_ulong num_key, zend_string * key) { \
|
||||
if (key == NULL) { \
|
||||
php_error_docref(NULL, E_WARNING, \
|
||||
"Skipping numeric key " ZEND_LONG_FMT, num_key);\
|
||||
continue; \
|
||||
} \
|
||||
if ((struc = php_get_session_var(key))) { \
|
||||
zval *struc = php_get_session_var(key); \
|
||||
if (struc) { \
|
||||
code; \
|
||||
} \
|
||||
} ZEND_HASH_FOREACH_END(); \
|
||||
|
||||
@@ -567,8 +567,6 @@ static void php_session_save_current_state(bool write)
|
||||
|
||||
static void php_session_normalize_vars(void)
|
||||
{
|
||||
PS_ENCODE_VARS;
|
||||
|
||||
IF_SESSION_VARS() {
|
||||
PS_ENCODE_LOOP(
|
||||
if (Z_TYPE_P(struc) == IS_PTR) {
|
||||
@@ -988,7 +986,6 @@ PS_SERIALIZER_ENCODE_FUNC(php_binary)
|
||||
{
|
||||
smart_str buf = {0};
|
||||
php_serialize_data_t var_hash;
|
||||
PS_ENCODE_VARS;
|
||||
|
||||
PHP_VAR_SERIALIZE_INIT(var_hash);
|
||||
|
||||
@@ -1052,7 +1049,6 @@ PS_SERIALIZER_ENCODE_FUNC(php)
|
||||
smart_str buf = {0};
|
||||
php_serialize_data_t var_hash;
|
||||
bool fail = false;
|
||||
PS_ENCODE_VARS;
|
||||
|
||||
PHP_VAR_SERIALIZE_INIT(var_hash);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user