diff --git a/ext/session/mod_user_class.c b/ext/session/mod_user_class.c index a2ab3c0615c2..b10a2956d20c 100644 --- a/ext/session/mod_user_class.c +++ b/ext/session/mod_user_class.c @@ -16,13 +16,14 @@ #include "php.h" #include "php_session.h" +#include "mod_user.h" #define PS_SANITY_CHECK \ if (PS(session_status) != php_session_active) { \ zend_throw_error(NULL, "Session is not active"); \ RETURN_THROWS(); \ } \ - if (PS(default_mod) == NULL) { \ + if (PS(default_mod) == NULL || PS(default_mod) == ps_user_ptr) { \ zend_throw_error(NULL, "Cannot call default session handler"); \ RETURN_THROWS(); \ } diff --git a/ext/session/tests/user_session_module/gh25307.phpt b/ext/session/tests/user_session_module/gh25307.phpt new file mode 100644 index 000000000000..c4ce666dd548 --- /dev/null +++ b/ext/session/tests/user_session_module/gh25307.phpt @@ -0,0 +1,24 @@ +--TEST-- +GH-25307 (NULL ps_files dereference in ps_files_close at shutdown) +--EXTENSIONS-- +session +--SKIPIF-- + +--CREDITS-- +YuanchengJiang +--FILE-- +open("", ""); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} +echo "Done\n"; +?> +--EXPECT-- +Cannot call default session handler +Done