aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/gamedb.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-12-02 12:50:21 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-12-02 12:50:21 +0100
commit8bd157ea55d34a83002e58ad446f27ea970cd75f (patch)
tree2f5ee6b51f4dc2c407be81311a39c82fc6bade7b /FICS/gamedb.c
parent59469ea9107cb75ec60abf14440292ea691ab194 (diff)
ReadGameAttrs: handle fgets() nullret
Diffstat (limited to 'FICS/gamedb.c')
-rw-r--r--FICS/gamedb.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c
index 3a5c50c..fce8ea3 100644
--- a/FICS/gamedb.c
+++ b/FICS/gamedb.c
@@ -1333,7 +1333,7 @@ ReadGameAttrs(FILE *fp, char *fname, int g)
{
char *attr, *value;
char line[MAX_GLINE_SIZE] = { '\0' };
- int len;
+ int len = 0;
int version = 0;
if (fgets(line, sizeof line, fp) == NULL) {
@@ -1352,7 +1352,8 @@ ReadGameAttrs(FILE *fp, char *fname, int g)
} else {
do {
if ((len = strlen(line)) <= 1) {
- fgets(line, sizeof line, fp);
+ if (fgets(line, sizeof line, fp) == NULL)
+ break;
continue;
}
@@ -1367,7 +1368,8 @@ ReadGameAttrs(FILE *fp, char *fname, int g)
if (!*value) {
fprintf(stderr, "FICS: Error reading file %s\n",
fname);
- fgets(line, sizeof line, fp);
+ if (fgets(line, sizeof line, fp) == NULL)
+ break;
continue;
}
@@ -1378,7 +1380,8 @@ ReadGameAttrs(FILE *fp, char *fname, int g)
if (!*value) {
fprintf(stderr, "FICS: Error reading file %s\n",
fname);
- fgets(line, sizeof line, fp);
+ if (fgets(line, sizeof line, fp) == NULL)
+ break;
continue;
}
@@ -1387,7 +1390,8 @@ ReadGameAttrs(FILE *fp, char *fname, int g)
if (got_attr_value(g, attr, value, fp, fname))
return -1;
- fgets(line, sizeof line, fp);
+ if (fgets(line, sizeof line, fp) == NULL)
+ break;
} while (!feof(fp));
}