Changed: Check return value of fwrite

This commit is contained in:
kervala 2016-12-19 15:50:54 +01:00
parent 3f8aa231a5
commit 4e9788116f
2 changed files with 25 additions and 6 deletions

View file

@ -495,15 +495,30 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes
if (_NeedHeader)
{
const char *hs = HeaderString();
fwrite (hs, strlen (hs), 1, _FilePointer);
if (fwrite(hs, strlen(hs), 1, _FilePointer) != 1)
{
printf("Unable to write header: %s\n", hs);
}
_NeedHeader = false;
}
if (!str.empty())
fwrite (str.c_str(), str.size(), 1, _FilePointer);
{
if (fwrite(str.c_str(), str.size(), 1, _FilePointer) != 1)
{
printf("Unable to write string: %s\n", str.c_str());
}
}
if (!args.CallstackAndLog.empty())
fwrite (args.CallstackAndLog.c_str(), args.CallstackAndLog.size (), 1, _FilePointer);
{
if (fwrite(args.CallstackAndLog.c_str(), args.CallstackAndLog.size(), 1, _FilePointer) != 1)
{
printf("Unable to write call stack: %s\n", args.CallstackAndLog.c_str());
}
}
fflush (_FilePointer);
}

View file

@ -1652,7 +1652,11 @@ void CClientEditionModule::saveUserComponentFile(const std::string& filename, bo
FILE* output = nlfopen(uncompressedName, "wb");
if (output)
{
fwrite(component->UncompressedData, sizeof(char) , component->UncompressedDataLength, output);
if (fwrite(component->UncompressedData, sizeof(char), component->UncompressedDataLength, output) != component->UncompressedDataLength)
{
nlwarning("Unable to write %s", component->UncompressedData);
}
fclose(output);
}
}