summaryrefslogtreecommitdiff
path: root/ext/session
diff options
context:
space:
mode:
authorAlexander Feldman <sasha@php.net>2000-10-23 13:10:01 +0000
committerAlexander Feldman <sasha@php.net>2000-10-23 13:10:01 +0000
commit7c11cfaf038508daf17fc20e1f0ab39f5a9729b7 (patch)
treefd41df719bd695a3778ae236573c51262ce05a04 /ext/session
parent86c0d81253f62414384c6c92f9283e545dfccfc7 (diff)
downloadphp-git-7c11cfaf038508daf17fc20e1f0ab39f5a9729b7.tar.gz
Fixed a bug in session.c. If the user calls session_module_name with a
parameter, then the mod_data pointer is initialized to NULL and then php_session_save_current_state did not check this value before referencing the pointer. Added a check in php_session_save_current_state.
Diffstat (limited to 'ext/session')
-rw-r--r--ext/session/session.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/session/session.c b/ext/session/session.c
index 4ab1377dbb..78cbd794cd 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -579,12 +579,15 @@ static void php_session_save_current_state(PSLS_D)
}
}
- val = php_session_encode(&vallen PSLS_CC);
- if (val) {
- ret = PS(mod)->write(&PS(mod_data), PS(id), val, vallen);
- efree(val);
- } else
- ret = PS(mod)->write(&PS(mod_data), PS(id), "", 0);
+ if (PS(mod_data)) {
+ val = php_session_encode(&vallen PSLS_CC);
+ if (val) {
+ ret = PS(mod)->write(&PS(mod_data), PS(id), val, vallen);
+ efree(val);
+ } else {
+ ret = PS(mod)->write(&PS(mod_data), PS(id), "", 0);
+ }
+ }
if (ret == FAILURE)
php_error(E_WARNING, "Failed to write session data (%s). Please "
@@ -594,7 +597,8 @@ static void php_session_save_current_state(PSLS_D)
PS(save_path));
- PS(mod)->close(&PS(mod_data));
+ if (PS(mod_data))
+ PS(mod)->close(&PS(mod_data));
}
static char *month_names[] = {