From 10ca4c7527122efde0300205deaa6c0143f07219 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 21 Oct 2016 19:18:15 -0700 Subject: More checks for localtime() and gmtime() returning NULL. And some comments in the case where we're converting the result of time() - if your machine's idea of time predates January 1, 1970, 00:00:00 UTC, it'll crash on Windows, but that's not a case where a *file* can cause the problem due either to a bad file time stamp or bad time stamps in the file. Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498 Reviewed-on: https://code.wireshark.org/review/18369 Reviewed-by: Guy Harris --- ui/console.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ui/console.c') diff --git a/ui/console.c b/ui/console.c index 94c6e5ac3f..2f3064b290 100644 --- a/ui/console.c +++ b/ui/console.c @@ -91,11 +91,16 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level, /* create a "timestamp" */ time(&curr); today = localtime(&curr); - - fprintf(stderr, "%02d:%02d:%02d %8s %s %s\n", - today->tm_hour, today->tm_min, today->tm_sec, - log_domain != NULL ? log_domain : "", - level, message); + if (today != NULL) { + fprintf(stderr, "%02d:%02d:%02d %8s %s %s\n", + today->tm_hour, today->tm_min, today->tm_sec, + log_domain != NULL ? log_domain : "", + level, message); + } else { + fprintf(stderr, "Time not representable %8s %s %s\n", + log_domain != NULL ? log_domain : "", + level, message); + } #ifdef _WIN32 if(log_level & G_LOG_LEVEL_ERROR) { /* wait for a key press before the following error handler will terminate the program -- cgit v1.2.1