Changed: Check return value of fwrite

--HG--
branch : develop
This commit is contained in:
kervala 2016-12-19 15:50:54 +01:00
parent 7aabc217b0
commit 4e0a19205c
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) if (_NeedHeader)
{ {
const char *hs = HeaderString(); 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; _NeedHeader = false;
} }
if (!str.empty()) 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()) 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); fflush (_FilePointer);
} }

View file

@ -1652,7 +1652,11 @@ void CClientEditionModule::saveUserComponentFile(const std::string& filename, bo
FILE* output = nlfopen(uncompressedName, "wb"); FILE* output = nlfopen(uncompressedName, "wb");
if (output) 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); fclose(output);
} }
} }