cvs: php4 /ext/session session.c

From: Date: Wed, 06 Mar 2002 00:34:58 +0000
Subject: cvs: php4 /ext/session session.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-9707@lists.php.net to get a copy of this message
yohgaki Tue Mar 5 19:34:58 2002 EDT Modified files: /php4/ext/session session.c Log: Return FALSE when session_module_name() failed. Fix a little leak. Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.284 php4/ext/session/session.c:1.285 --- php4/ext/session/session.c:1.284 Tue Mar 5 19:26:38 2002 +++ php4/ext/session/session.c Tue Mar 5 19:34:57 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: session.c,v 1.284 2002/03/06 00:26:38 yohgaki Exp $ */ +/* $Id: session.c,v 1.285 2002/03/06 00:34:57 yohgaki Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1076,9 +1076,7 @@ { zval **p_name; int ac = ZEND_NUM_ARGS(); - char *old; - - old = safe_estrdup(PS(mod)->name); + char *old = NULL; if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &p_name) == FAILURE) WRONG_PARAM_COUNT; @@ -1086,26 +1084,34 @@ if (ac == 1) { ps_module *tempmod; + if (PS(session_status) & (PS_ACTIVE|PS_ERROR)) { + php_error(E_NOTICE, "%s() cannot set session module name once session is started. " + "Current session save handler (%s)", + get_active_function_name(TSRMLS_C), + (PS(mod)->name ? PS(mod)->name : "none")); + RETURN_FALSE; + } + convert_to_string_ex(p_name); tempmod = _php_find_ps_module(Z_STRVAL_PP(p_name) TSRMLS_CC); - if (tempmod) { - if (PS(mod_data)) - PS(mod)->close(&PS(mod_data)); - PS(mod) = tempmod; - PS(mod_data) = NULL; - } else { - efree(old); - php_error(E_ERROR, "Cannot find named PHP session module (%s)", - Z_STRVAL_PP(p_name)); + if (!tempmod) { + php_error(E_NOTICE, "Cannot find named PHP session module (%s)", + Z_STRVAL_PP(p_name)); RETURN_FALSE; } + if (PS(mod_data)) + PS(mod)->close(&PS(mod_data) TSRMLS_CC); + PS(mod) = tempmod; + PS(mod_data) = NULL; + PS(rinit_mod) = 1; } + old = safe_estrdup(PS(mod)->name); RETVAL_STRING(old, 0); } /* }}} */ -/* {{{ proto void session_set_save_handler(string open, string close, string read, string write, string destroy, string gc) +/* {{{ proto bool session_set_save_handler(string open, string close, string read, string write, string destroy, string gc) Sets user-level functions */ PHP_FUNCTION(session_set_save_handler) {

« previous php.cvs (#9707) next »