summaryrefslogtreecommitdiffstats
path: root/larn
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2010-04-02 21:40:00 +0000
committerchristos <christos@NetBSD.org>2010-04-02 21:40:00 +0000
commita53a36daca29fbcfba1da1f2e0c4f0c8e9cef879 (patch)
tree0d61fca43da18d9f19b0521487eb7a8fe439565d /larn
parent8121144c17f21c9a9502c8c7534d2ba4c3c9a5aa (diff)
downloadbsdgames-darwin-a53a36daca29fbcfba1da1f2e0c4f0c8e9cef879.tar.gz
bsdgames-darwin-a53a36daca29fbcfba1da1f2e0c4f0c8e9cef879.tar.zst
bsdgames-darwin-a53a36daca29fbcfba1da1f2e0c4f0c8e9cef879.zip
ctime can return NULL.
Diffstat (limited to 'larn')
-rw-r--r--larn/scores.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/larn/scores.c b/larn/scores.c
index a6a47cf6..b33150c5 100644
--- a/larn/scores.c
+++ b/larn/scores.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.18 2009/08/12 08:04:05 dholland Exp $ */
+/* $NetBSD: scores.c,v 1.19 2010/04/02 21:40:00 christos Exp $ */
/*
* scores.c Larn is copyrighted 1986 by Noah Morgan.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: scores.c,v 1.18 2009/08/12 08:04:05 dholland Exp $");
+__RCSID("$NetBSD: scores.c,v 1.19 2010/04/02 21:40:00 christos Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/times.h>
@@ -772,6 +772,7 @@ diedlog()
{
int n;
char *p;
+ static char q[] = "?";
struct stat stbuf;
lcreat((char *) 0);
if (lopen(logfile) < 0) {
@@ -784,9 +785,12 @@ diedlog()
}
for (n = stbuf.st_size / sizeof(struct log_fmt); n > 0; --n) {
lrfill((char *) &logg, sizeof(struct log_fmt));
- p = ctime(&logg.diedtime);
- p[16] = '\n';
- p[17] = 0;
+ if ((p = ctime(&logg.diedtime)) == NULL)
+ p = q;
+ else {
+ p[16] = '\n';
+ p[17] = 0;
+ }
lprintf("Score: %ld, Diff: %ld, %s %s on %ld at %s", (long) (logg.score), (long) (logg.diff), logg.who, logg.what, (long) (logg.cavelev), p + 4);
#ifdef EXTRA
if (logg.moves <= 0)