From: H.G. Muller Date: Tue, 11 Sep 2012 14:08:51 +0000 (+0200) Subject: Fix printing of date with rating X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=696676da82327e74a1e2addf74702c5a309ce8b7;p=capablanca.git 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. --- 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");