summaryrefslogtreecommitdiff
path: root/ext/date/php_date.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r--ext/date/php_date.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 49f76d6a06..a1159691d1 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -578,16 +578,18 @@ static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC)
{
struct tm *ta, tmbuf;
time_t the_time;
- char *tzid;
+ char *tzid = NULL;
the_time = time(NULL);
ta = php_localtime_r(&the_time, &tmbuf);
- tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst);
+ if (ta) {
+ tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst);
+ }
if (! tzid) {
tzid = "UTC";
}
- php_error_docref(NULL TSRMLS_CC, E_STRICT, DATE_TZ_ERRMSG "We selected '%s' for '%s/%.1f/%s' instead", tzid, ta->tm_zone, (float) (ta->tm_gmtoff / 3600), ta->tm_isdst ? "DST" : "no DST");
+ php_error_docref(NULL TSRMLS_CC, E_STRICT, DATE_TZ_ERRMSG "We selected '%s' for '%s/%.1f/%s' instead", tzid, ta ? ta->tm_zone : "Unknown", ta ? (float) (ta->tm_gmtoff / 3600) : 0, ta ? (ta->tm_isdst ? "DST" : "no DST") : "Unknown");
return tzid;
}
#endif