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
|
@ -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,12 +4537,15 @@ void update_subscriptions(void)
|
||||||
|
|
||||||
sprintf(zText, "subscriptions.%u", turn);
|
sprintf(zText, "subscriptions.%u", turn);
|
||||||
F = fopen(zText, "w");
|
F = fopen(zText, "w");
|
||||||
|
if (F) {
|
||||||
|
faction *f;
|
||||||
for (f = factions; f != NULL; f = f->next) {
|
for (f = factions; f != NULL; f = f->next) {
|
||||||
fprintf(F, "%s:%u:%s:%s:%u:\n",
|
fprintf(F, "%s:%u:%s:%s:%u:\n",
|
||||||
itoa36(f->no), f->subscription, f->email, dbrace(f->race), f->lastorders);
|
itoa36(f->no), f->subscription, f->email, dbrace(f->race), f->lastorders);
|
||||||
}
|
}
|
||||||
fclose(F);
|
fclose(F);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
cansee(const faction * f, const region * r, const unit * u, int modifier)
|
cansee(const faction * f, const region * r, const unit * u, int modifier)
|
||||||
|
|
Loading…
Reference in New Issue