diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-11-23 23:46:40 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-11-23 23:46:40 +0100 |
commit | fb1545bccdd22866504923fd856a203dd312c1ee (patch) | |
tree | 94cc5ec4e41d8b94fc5cc6651cf8bbb302d668a5 /FICS | |
parent | 96904ed9b2688f2712e3a2a78e3c40bcfd400742 (diff) |
Check the retval of localtime()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/gamedb.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c index 6fa0ae2..dea8a67 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -553,6 +553,7 @@ movesToString(int g, int pgn) char tmp[160] = { '\0' }; int i, col; int wr, br; + struct tm *tm_ptr = NULL; time_t curTime; wr = garray[g].white_rating; @@ -569,11 +570,15 @@ movesToString(int g, int pgn) bstr[garray[g].type], serv_name, serv_loc); - strftime(tmp, sizeof(tmp), - "[Date \"%Y.%m.%d\"]\n" - "[Time \"%H:%M:%S\"]\n", - localtime(&curTime)); // XXX - mstrlcat(gameString, tmp, sizeof gameString); + + if ((tm_ptr = localtime(&curTime)) != NULL) { + strftime(tmp, sizeof(tmp), + "[Date \"%Y.%m.%d\"]\n" + "[Time \"%H:%M:%S\"]\n", + tm_ptr); + mstrlcat(gameString, tmp, sizeof gameString); + } else + warn("%s: localtime", __func__); msnprintf(tmp, sizeof tmp, "[Round \"-\"]\n" |