From 696676da82327e74a1e2addf74702c5a309ce8b7 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 11 Sep 2012 16:08:51 +0200 Subject: [PATCH] Fix printing of date with rating The old code was not safe: it passed a (time_t*) pointing to an (in), which included garbage if time_t was of larger size. This again made localtime return a null-pointer, which would crash strftime. --- lasker-2.2.3/src/comproc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/lasker-2.2.3/src/comproc.c b/lasker-2.2.3/src/comproc.c index 97522e0..0487f88 100644 --- a/lasker-2.2.3/src/comproc.c +++ b/lasker-2.2.3/src/comproc.c @@ -125,9 +125,10 @@ static void com_stats_rating(char *hdr, struct statistics * stats, char *dest, l ratstr(stats->rating), current_sterr(stats->sterr, now-stats->ltime), stats->win, stats->los, stats->dra, stats->num); if (stats->whenbest) { + time_t besttime = stats->whenbest; // [HGM] time_t could have larger size than int, so don't pass localtime a pointer to it sprintf(tmp, " %d", stats->best); strcat(dest, tmp); - strftime(tmp, sizeof(tmp), " (%d-%b-%Y)", localtime((time_t *) & stats->whenbest)); + strftime(tmp, sizeof(tmp), " (%d-%b-%Y)", localtime(&besttime)); strcat(dest, tmp); } strcat(dest, "\n"); -- 1.7.0.4