]> granicus.if.org Git - php/commitdiff
- Fixed bug #25780 (ext/session: invalid session.cookie_lifetime causes crash in...
authorfoobar <sniper@php.net>
Wed, 8 Oct 2003 10:22:51 +0000 (10:22 +0000)
committerfoobar <sniper@php.net>
Wed, 8 Oct 2003 10:22:51 +0000 (10:22 +0000)
ext/session/session.c

index 22521626b8b103f5cad84b1ede067067d00bd1c9..0eac74f32727712865faa0aadda851a5af2f06c1 100644 (file)
@@ -957,13 +957,17 @@ static void php_session_send_cookie(TSRMLS_D)
        
        if (PS(cookie_lifetime) > 0) {
                struct timeval tv;
+               time_t t;
                
                gettimeofday(&tv, NULL);
-               date_fmt = php_std_date(tv.tv_sec + PS(cookie_lifetime) TSRMLS_CC);
+               t = tv.tv_sec + PS(cookie_lifetime);
                
-               smart_str_appends(&ncookie, COOKIE_EXPIRES);
-               smart_str_appends(&ncookie, date_fmt);
-               efree(date_fmt);
+               if (t > 0) {
+                       date_fmt = php_std_date(t TSRMLS_CC);
+                       smart_str_appends(&ncookie, COOKIE_EXPIRES);
+                       smart_str_appends(&ncookie, date_fmt);
+                       efree(date_fmt);
+               }
        }
 
        if (PS(cookie_path)[0]) {