aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeff Garzik <[email protected]>2012-04-22 13:59:24 -0400
committerJeff Garzik <[email protected]>2012-04-23 14:14:36 -0400
commit5aa0b2382515eb92fe249a106059f3b6a9328d26 (patch)
treebea59d8369abddbe0f517270708404822a98b198 /src
parentAdd casts for unavoidable signed/unsigned comparisons (diff)
downloaddiscoin-5aa0b2382515eb92fe249a106059f3b6a9328d26.tar.xz
discoin-5aa0b2382515eb92fe249a106059f3b6a9328d26.zip
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')
-rw-r--r--src/main.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.h b/src/main.h
index 423891c3b..262e77e80 100644
--- a/src/main.h
+++ b/src/main.h
@@ -944,9 +944,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