forked from github/server
CID 22506: Dereference null return value (NULL_RETURNS)
always check fopen success
This commit is contained in:
parent
204b4d6b93
commit
d6bc1c3119
14
src/laws.c
14
src/laws.c
|
@ -4512,7 +4512,6 @@ void update_subscriptions(void)
|
||||||
{
|
{
|
||||||
FILE *F;
|
FILE *F;
|
||||||
char zText[MAX_PATH];
|
char zText[MAX_PATH];
|
||||||
faction *f;
|
|
||||||
|
|
||||||
strlcpy(zText, basepath(), sizeof(zText));
|
strlcpy(zText, basepath(), sizeof(zText));
|
||||||
strlcat(zText, "/subscriptions", sizeof(zText));
|
strlcat(zText, "/subscriptions", sizeof(zText));
|
||||||
|
@ -4524,6 +4523,8 @@ void update_subscriptions(void)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char zFaction[5];
|
char zFaction[5];
|
||||||
int subscription, fno;
|
int subscription, fno;
|
||||||
|
faction *f;
|
||||||
|
|
||||||
if (fscanf(F, "%d %s", &subscription, zFaction) <= 0)
|
if (fscanf(F, "%d %s", &subscription, zFaction) <= 0)
|
||||||
break;
|
break;
|
||||||
fno = atoi36(zFaction);
|
fno = atoi36(zFaction);
|
||||||
|
@ -4536,11 +4537,14 @@ void update_subscriptions(void)
|
||||||
|
|
||||||
sprintf(zText, "subscriptions.%u", turn);
|
sprintf(zText, "subscriptions.%u", turn);
|
||||||
F = fopen(zText, "w");
|
F = fopen(zText, "w");
|
||||||
for (f = factions; f != NULL; f = f->next) {
|
if (F) {
|
||||||
fprintf(F, "%s:%u:%s:%s:%u:\n",
|
faction *f;
|
||||||
itoa36(f->no), f->subscription, f->email, dbrace(f->race), f->lastorders);
|
for (f = factions; f != NULL; f = f->next) {
|
||||||
|
fprintf(F, "%s:%u:%s:%s:%u:\n",
|
||||||
|
itoa36(f->no), f->subscription, f->email, dbrace(f->race), f->lastorders);
|
||||||
|
}
|
||||||
|
fclose(F);
|
||||||
}
|
}
|
||||||
fclose(F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
Loading…
Reference in New Issue