summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-06-07 08:46:32 +0000
committerAntony Dovgal <tony2001@php.net>2007-06-07 08:46:32 +0000
commita9f6f71460602d00a3497b8e848b857e8055a7d6 (patch)
tree8ccb857e338853eff09559040c067727eddf29f7 /ext
parent26255ddf1af5c6bc27ff9c0ae942d2c4e720b652 (diff)
downloadphp-git-a9f6f71460602d00a3497b8e848b857e8055a7d6.tar.gz
check return value of *time_r() functions for NULL
more checks will follow
Diffstat (limited to 'ext')
-rw-r--r--ext/calendar/cal_unix.c5
-rw-r--r--ext/date/php_date.c8
-rw-r--r--ext/mime_magic/mime_magic.c3
3 files changed, 12 insertions, 4 deletions
diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c
index 85ad681cfe..59038ff49f 100644
--- a/ext/calendar/cal_unix.c
+++ b/ext/calendar/cal_unix.c
@@ -47,8 +47,11 @@ PHP_FUNCTION(unixtojd)
}
ta = php_localtime_r(&timestamp, &tmbuf);
+ if (!ta) {
+ RETURN_FALSE;
+ }
+
jdate = GregorianToSdn(ta->tm_year+1900, ta->tm_mon+1, ta->tm_mday);
-
RETURN_LONG(jdate);
}
/* }}} */
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 91046cee00..9a95fc3aa3 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -583,16 +583,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
diff --git a/ext/mime_magic/mime_magic.c b/ext/mime_magic/mime_magic.c
index 9c399c3c6a..502032e1b6 100644
--- a/ext/mime_magic/mime_magic.c
+++ b/ext/mime_magic/mime_magic.c
@@ -1764,6 +1764,9 @@ static void mprint(union VALUETYPE *p, struct magic *m)
{
char ctimebuf[52];
pp = php_ctime_r((time_t *) &p->l, ctimebuf);
+ if (!pp) {
+ return;
+ }
if ((rt = strchr(pp, '\n')) != NULL) {
*rt = '\0';
}