CID 22507: Dereference null return value (NULL_RETURNS)

checking fopen results
This commit is contained in:
Enno Rehling 2015-10-30 12:55:30 +01:00
parent d6bc1c3119
commit 8f7f182c91
1 changed files with 17 additions and 14 deletions

View File

@ -1705,23 +1705,26 @@ int crwritemap(const char *filename)
FILE *F = fopen(filename, "w"); FILE *F = fopen(filename, "w");
region *r; region *r;
fprintf(F, "VERSION %d\n", C_REPORT_VERSION); if (F) {
fputs("\"UTF-8\";charset\n", F); fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
fputs("\"UTF-8\";charset\n", F);
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
plane *pl = rplane(r); plane *pl = rplane(r);
int plid = plane_id(pl); int plid = plane_id(pl);
if (plid) { if (plid) {
fprintf(F, "REGION %d %d %d\n", r->x, r->y, plid); fprintf(F, "REGION %d %d %d\n", r->x, r->y, plid);
}
else {
fprintf(F, "REGION %d %d\n", r->x, r->y);
}
fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale),
LOC(default_locale, terrain_name(r)));
} }
else { fclose(F);
fprintf(F, "REGION %d %d\n", r->x, r->y); return 0;
}
fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale),
LOC(default_locale, terrain_name(r)));
} }
fclose(F); return EOF;
return 0;
} }
void register_cr(void) void register_cr(void)