aboutsummaryrefslogtreecommitdiffstats
path: root/epan/to_str.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2009-12-11 08:08:05 +0000
committerGuy Harris <guy@alum.mit.edu>2009-12-11 08:08:05 +0000
commit818b8c3878496174f7e8c10fe24952088385e9a9 (patch)
tree95a02781af32b3c1bd03e7847fea45eece8d030e /epan/to_str.c
parent38316e048327f9ea3aedc3825925ff68946fcbf8 (diff)
Protect against localtime() failing.
svn path=/trunk/; revision=31238
Diffstat (limited to 'epan/to_str.c')
-rw-r--r--epan/to_str.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/epan/to_str.c b/epan/to_str.c
index 6e0b827ce1..dcd070eab2 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -326,15 +326,18 @@ abs_time_to_str(nstime_t *abs_time, gboolean show_as_utc)
zonename = "UTC";
} else {
tmp = localtime(&abs_time->secs);
+ if (tmp) {
#if defined(HAVE_TM_ZONE)
- zonename = tmp->tm_zone;
+ zonename = tmp->tm_zone;
#elif defined(HAVE_TZNAME)
- zonename = tzname[tmp->tm_isdst];
+ zonename = tzname[tmp->tm_isdst];
#elif _WIN32
- zonename = _tzname[tmp->tm_isdst];
+ zonename = _tzname[tmp->tm_isdst];
#else
- zonename = tmp->tm_isdst ? "?ST" : "?DT";
+ zonename = tmp->tm_isdst ? "?ST" : "?DT";
#endif
+ } else
+ zonename = NULL;
}
if (tmp) {
buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d.%09ld %s",
@@ -371,15 +374,18 @@ abs_time_secs_to_str(time_t abs_time, gboolean show_as_utc)
zonename = "UTC";
} else {
tmp = localtime(&abs_time);
+ if (tmp) {
#if defined(HAVE_TM_ZONE)
- zonename = tmp->tm_zone;
+ zonename = tmp->tm_zone;
#elif defined(HAVE_TZNAME)
- zonename = tzname[tmp->tm_isdst];
+ zonename = tzname[tmp->tm_isdst];
#elif _WIN32
- zonename = _tzname[tmp->tm_isdst];
+ zonename = _tzname[tmp->tm_isdst];
#else
- zonename = tmp->tm_isdst ? "?ST" : "?DT";
+ zonename = tmp->tm_isdst ? "?ST" : "?DT";
#endif
+ } else
+ zonename = NULL;
}
if (tmp) {
buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d %s",