diff options
author | Jeff Garzik <jgarzik@exmulti.com> | 2012-04-22 13:59:24 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-04-24 01:00:15 -0400 |
commit | c21121752d95ee241eb616a9b958fc662c874803 (patch) | |
tree | 68a4179cc5469eb3e27c668c604f3401e9105919 /src/main.h | |
parent | d0fe14ffecda4af98ffe7b1523f9a903bf7518a0 (diff) | |
download | bitcoin-c21121752d95ee241eb616a9b958fc662c874803.tar.xz |
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.
Diffstat (limited to 'src/main.h')
-rw-r--r-- | src/main.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.h b/src/main.h index de674b5bb1..e835cdd7bb 100644 --- a/src/main.h +++ b/src/main.h @@ -961,9 +961,10 @@ public: fileout << FLATDATA(pchMessageStart) << nSize; // Write block - nBlockPosRet = ftell(fileout); - if (nBlockPosRet == -1) + long fileOutPos = ftell(fileout); + if (fileOutPos < 0) return error("CBlock::WriteToDisk() : ftell failed"); + nBlockPosRet = fileOutPos; fileout << *this; // Flush stdio buffers and commit to disk before returning |