Commit e1b2f1f5cb8 for php.net
commit e1b2f1f5cb82a8a8bcfae5935451528a598478ee
Author: Gina Peter Banyard <girgias@php.net>
Date: Mon Feb 9 11:28:45 2026 +0000
ext/session: move variable initialization out of if condition
diff --git a/ext/session/session.c b/ext/session/session.c
index 6930ea8ca2d..d9a4e2b5a4d 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2978,14 +2978,12 @@ static PHP_MINFO_FUNCTION(session)
static bool early_find_sid_in(zval *dest, int where)
{
- zval *potential_session_id;
-
if (Z_ISUNDEF(PG(http_globals)[where])) {
return false;
}
- if ((potential_session_id = zend_hash_find(Z_ARRVAL(PG(http_globals)[where]), PS(session_name)))
- && Z_TYPE_P(potential_session_id) == IS_STRING) {
+ zval *potential_session_id = zend_hash_find(Z_ARRVAL(PG(http_globals)[where]), PS(session_name));
+ if (potential_session_id && Z_TYPE_P(potential_session_id) == IS_STRING) {
zval_ptr_dtor(dest);
ZVAL_COPY_DEREF(dest, potential_session_id);
return true;
@@ -3013,15 +3011,15 @@ static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *pro
static bool php_check_cancel_upload(const php_session_rfc1867_progress *progress)
{
- zval *progress_ary, *cancel_upload;
-
- if ((progress_ary = zend_symtable_find(Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))), progress->key.s)) == NULL) {
+ const zval *progress_ary = zend_symtable_find(Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))), progress->key.s);
+ if (progress_ary == NULL) {
return false;
}
if (Z_TYPE_P(progress_ary) != IS_ARRAY) {
return false;
}
- if ((cancel_upload = zend_hash_str_find(Z_ARRVAL_P(progress_ary), ZEND_STRL("cancel_upload"))) == NULL) {
+ const zval *cancel_upload = zend_hash_str_find(Z_ARRVAL_P(progress_ary), ZEND_STRL("cancel_upload"));
+ if (cancel_upload == NULL) {
return false;
}
return Z_TYPE_P(cancel_upload) == IS_TRUE;