Browse Source

CBlock::WriteToDisk() properly checks ftell(3) for error return

Rather than storing ftell(3)'s return value -- a long -- in an
unsigned int, we store and check a properly typed temp.  Then, assured a
non-negative value, we store in nBlockPosRet.
0.8
Jeff Garzik 13 years ago committed by Jeff Garzik
parent
commit
5aa0b23825
  1. 5
      src/main.h

5
src/main.h

@ -944,9 +944,10 @@ public:
fileout << FLATDATA(pchMessageStart) << nSize; fileout << FLATDATA(pchMessageStart) << nSize;
// Write block // Write block
nBlockPosRet = ftell(fileout); long fileOutPos = ftell(fileout);
if (nBlockPosRet == -1) if (fileOutPos < 0)
return error("CBlock::WriteToDisk() : ftell failed"); return error("CBlock::WriteToDisk() : ftell failed");
nBlockPosRet = fileOutPos;
fileout << *this; fileout << *this;
// Flush stdio buffers and commit to disk before returning // Flush stdio buffers and commit to disk before returning

Loading…
Cancel
Save