Skip to content

Commit e1b2f1f

Browse files
committed
ext/session: move variable initialization out of if condition
1 parent 8af0562 commit e1b2f1f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ext/session/session.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,14 +2978,12 @@ static PHP_MINFO_FUNCTION(session)
29782978

29792979
static bool early_find_sid_in(zval *dest, int where)
29802980
{
2981-
zval *potential_session_id;
2982-
29832981
if (Z_ISUNDEF(PG(http_globals)[where])) {
29842982
return false;
29852983
}
29862984

2987-
if ((potential_session_id = zend_hash_find(Z_ARRVAL(PG(http_globals)[where]), PS(session_name)))
2988-
&& Z_TYPE_P(potential_session_id) == IS_STRING) {
2985+
zval *potential_session_id = zend_hash_find(Z_ARRVAL(PG(http_globals)[where]), PS(session_name));
2986+
if (potential_session_id && Z_TYPE_P(potential_session_id) == IS_STRING) {
29892987
zval_ptr_dtor(dest);
29902988
ZVAL_COPY_DEREF(dest, potential_session_id);
29912989
return true;
@@ -3013,15 +3011,15 @@ static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *pro
30133011

30143012
static bool php_check_cancel_upload(const php_session_rfc1867_progress *progress)
30153013
{
3016-
zval *progress_ary, *cancel_upload;
3017-
3018-
if ((progress_ary = zend_symtable_find(Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))), progress->key.s)) == NULL) {
3014+
const zval *progress_ary = zend_symtable_find(Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))), progress->key.s);
3015+
if (progress_ary == NULL) {
30193016
return false;
30203017
}
30213018
if (Z_TYPE_P(progress_ary) != IS_ARRAY) {
30223019
return false;
30233020
}
3024-
if ((cancel_upload = zend_hash_str_find(Z_ARRVAL_P(progress_ary), ZEND_STRL("cancel_upload"))) == NULL) {
3021+
const zval *cancel_upload = zend_hash_str_find(Z_ARRVAL_P(progress_ary), ZEND_STRL("cancel_upload"));
3022+
if (cancel_upload == NULL) {
30253023
return false;
30263024
}
30273025
return Z_TYPE_P(cancel_upload) == IS_TRUE;

0 commit comments

Comments
 (0)