From e982b5749d7eb9b75e939eff0e41a0598848726e Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 17 Jul 2024 23:52:02 +0200 Subject: ReadGameAttrs: return value checking --- FICS/gamedb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'FICS') diff --git a/FICS/gamedb.c b/FICS/gamedb.c index 064a18a..394745c 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -1271,10 +1271,15 @@ ReadGameAttrs(FILE *fp, char *fname, int g) int len; int version = 0; - fgets(line, sizeof line, fp); + if (fgets(line, sizeof line, fp) == NULL) { + warnx("%s: fgets error", __func__); + return -1; + } - if (line[0] == 'v') - sscanf(line, "%*c %d", &version); + if (line[0] == 'v') { + if (sscanf(line, "%*c %d", &version) != 1) + warn("%s: failed to get version", __func__); + } if (version > 0) ReadV1GameFmt(&garray[g], fp, fname, version); -- cgit v1.2.3