]> granicus.if.org Git - php/commitdiff
MFH: fix segfault in session_module_name() when session.save_handler is empty
authorAntony Dovgal <tony2001@php.net>
Thu, 9 Dec 2004 14:21:13 +0000 (14:21 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 9 Dec 2004 14:21:13 +0000 (14:21 +0000)
ext/session/session.c

index e8c894644eb192fec5780212555fcc7a1fb3064a..6801467d13efc8603097087ae511fa9061b48dc9 100644 (file)
@@ -1222,11 +1222,21 @@ PHP_FUNCTION(session_module_name)
                }
                PS(mod_data) = NULL;
 
-               RETVAL_STRING(safe_estrdup(PS(mod)->s_name), 0);
-
+               if (PS(mod) && PS(mod)->s_name) {
+                       RETVAL_STRING(safe_estrdup(PS(mod)->s_name), 0);
+               }
+               else {
+                       RETVAL_EMPTY_STRING();
+               }
+               
                zend_alter_ini_entry("session.save_handler", sizeof("session.save_handler"), Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name), PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
        } else {
-               RETURN_STRING(safe_estrdup(PS(mod)->s_name), 0);
+               if (PS(mod) && PS(mod)->s_name) {
+                       RETURN_STRING(safe_estrdup(PS(mod)->s_name), 0);
+               }
+               else {
+                       RETURN_EMPTY_STRING();
+               }
        }
 }
 /* }}} */