CID 22441 Unchecked return value from library

This commit is contained in:
Enno Rehling 2015-11-04 12:03:26 +01:00
parent d6cd1feb48
commit c090f8e1f4
1 changed files with 15 additions and 11 deletions

View File

@ -3622,18 +3622,22 @@ battle *make_battle(region * r)
char zText[MAX_PATH]; char zText[MAX_PATH];
char zFilename[MAX_PATH]; char zFilename[MAX_PATH];
sprintf(zText, "%s/battles", basepath()); sprintf(zText, "%s/battles", basepath());
_mkdir(zText); if (_mkdir(zText) != 0) {
sprintf(zFilename, "%s/battle-%d-%s.log", zText, obs_count, simplename(r)); log_error("could not create subdirectory for battle logs: %s", zText);
battledebug = false;
}
else {
sprintf(zFilename, "%s/battle-%d-%s.log", zText, obs_count++, simplename(r));
bdebug = fopen(zFilename, "w"); bdebug = fopen(zFilename, "w");
if (!bdebug) if (!bdebug)
log_error("battles cannot be debugged\n"); log_error("battles cannot be debugged");
else { else {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
fwrite(utf8_bom, 1, 3, bdebug); fwrite(utf8_bom, 1, 3, bdebug);
fprintf(bdebug, "In %s findet ein Kampf statt:\n", rname(r, fprintf(bdebug, "In %s findet ein Kampf statt:\n", rname(r,
default_locale)); default_locale));
} }
obs_count++; }
} }
b->region = r; b->region = r;