Author: zooey Date: 2010-08-16 16:52:37 +0200 (Mon, 16 Aug 2010) New Revision: 38143 Changeset: http://dev.haiku-os.org/changeset/38143 Modified: haiku/trunk/src/kits/support/DateTime.cpp Log: * fix oversight that gmtime() and localtime() may return NULL, which would lead to a crash Modified: haiku/trunk/src/kits/support/DateTime.cpp =================================================================== --- haiku/trunk/src/kits/support/DateTime.cpp 2010-08-16 14:36:04 UTC (rev 38142) +++ haiku/trunk/src/kits/support/DateTime.cpp 2010-08-16 14:52:37 UTC (rev 38143) @@ -157,6 +157,9 @@ else timeinfo = localtime_r(&tv.tv_sec, &result); + if (timeinfo == NULL) + return BTime(); + int32 sec = timeinfo->tm_sec; return BTime(timeinfo->tm_hour, timeinfo->tm_min, (sec > 59) ? 59 : sec, tv.tv_usec); @@ -594,6 +597,9 @@ else timeinfo = localtime_r(&timer, &result); + if (timeinfo == NULL) + return BDate(); + return BDate(timeinfo->tm_year + 1900, timeinfo->tm_mon +1, timeinfo->tm_mday); } @@ -1385,7 +1391,7 @@ BTime time; time.AddSeconds(seconds % kSecondsPerDay); fTime.SetTime(time); - + BDate date(1970, 1, 1); date.AddDays(seconds / kSecondsPerDay); fDate.SetDate(date);