Skip to content

Commit aac1ec2

Browse files
hubertfhubertf
authored andcommitted
Adventure(6) should check for errors (e.g. disk full or quota
exceeded) when writing out saved games. Do so! Patch supplied by Joseph Myers <jsm28@cam.ac.uk> in PR 8016
1 parent d5f85ed commit aac1ec2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

games/adventure/save.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: save.c,v 1.6 1999/07/16 01:38:20 hubertf Exp $ */
1+
/* $NetBSD: save.c,v 1.7 1999/07/17 20:02:48 hubertf Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993
@@ -43,10 +43,11 @@
4343
#if 0
4444
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
4545
#else
46-
__RCSID("$NetBSD: save.c,v 1.6 1999/07/16 01:38:20 hubertf Exp $");
46+
__RCSID("$NetBSD: save.c,v 1.7 1999/07/17 20:02:48 hubertf Exp $");
4747
#endif
4848
#endif /* not lint */
4949

50+
#include <err.h>
5051
#include <stdio.h>
5152
#include <stdlib.h>
5253
#include "hdr.h"
@@ -152,7 +153,10 @@ save(outfile) /* Two passes on data: first to get checksum,
152153
*s = (*s ^ random()) & 0xFF; /* Lightly encrypt */
153154
fwrite(p->address, p->width, 1, out);
154155
}
155-
fclose(out);
156+
if (fclose(out) != 0) {
157+
warn("writing %s", outfile);
158+
return 1;
159+
}
156160
return 0;
157161
}
158162

0 commit comments

Comments
 (0)