- Fixed build on php-trunk
[m6w6/ext-http] / http_date_api.c
index 66033262bbc3ba5f73e3bb7a0d1b951aaaf0e87a..78a5da1938da7935a83acf587c4b6ccfe1ecaffd 100644 (file)
@@ -6,7 +6,7 @@
     | modification, are permitted provided that the conditions mentioned |
     | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2006, Michael Wallner <mike@php.net>            |
+    | Copyright (c) 2004-2010, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
@@ -141,20 +141,20 @@ static inline int check_tzone(const char *tzone)
 /* {{{ char *http_date(time_t) */
 PHP_HTTP_API char *_http_date(time_t t TSRMLS_DC)
 {
-       struct tm *gmtime, tmbuf;
+       char *date = NULL;
+       struct tm *gmtime = NULL, tmbuf;
 
+       memset(&tmbuf, 0, sizeof(tmbuf));
        if ((gmtime = php_gmtime_r(&t, &tmbuf))) {
-               char *date = ecalloc(1, 31);
-               snprintf(date, 30,
+               spprintf(&date, 0,
                        "%s, %02d %s %04d %02d:%02d:%02d GMT",
                        days[gmtime->tm_wday], gmtime->tm_mday,
                        months[gmtime->tm_mon], gmtime->tm_year + 1900,
                        gmtime->tm_hour, gmtime->tm_min, gmtime->tm_sec
                );
-               return date;
        }
 
-       return NULL;
+       return date;
 }
 /* }}} */