From: svost Date: Fri, 12 Feb 2016 11:17:16 +0000 (+0300) Subject: Fix V668 PVS Studio - deal with pointer and NULL X-Git-Tag: nvc-v0.5.6~81^2~2^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=31e9cb26642187e571f178ddcfa268ce7c4e56cc Fix V668 PVS Studio - deal with pointer and NULL --- diff --git a/src/main.cpp b/src/main.cpp index befcfaa..3291054 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2137,7 +2137,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos) return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str()); // Construct new block index object - CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this); + CBlockIndex* pindexNew = new(nothrow) CBlockIndex(nFile, nBlockPos, *this); if (!pindexNew) return error("AddToBlockIndex() : new CBlockIndex failed"); pindexNew->phashBlock = &hash; diff --git a/src/txdb-bdb.cpp b/src/txdb-bdb.cpp index bbfb656..5ce59b5 100644 --- a/src/txdb-bdb.cpp +++ b/src/txdb-bdb.cpp @@ -160,7 +160,7 @@ CBlockIndex static * InsertBlockIndex(uint256 hash) return (*mi).second; // Create new - CBlockIndex* pindexNew = new CBlockIndex(); + CBlockIndex* pindexNew = new(nothrow) CBlockIndex(); if (!pindexNew) throw runtime_error("LoadBlockIndex() : new CBlockIndex failed"); mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; diff --git a/src/txdb-leveldb.cpp b/src/txdb-leveldb.cpp index 4a7a3cf..97bf88c 100644 --- a/src/txdb-leveldb.cpp +++ b/src/txdb-leveldb.cpp @@ -325,7 +325,7 @@ static CBlockIndex *InsertBlockIndex(uint256 hash) return (*mi).second; // Create new - CBlockIndex* pindexNew = new CBlockIndex(); + CBlockIndex* pindexNew = new(nothrow) CBlockIndex(); if (!pindexNew) throw runtime_error("LoadBlockIndex() : new CBlockIndex failed"); mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; diff --git a/src/util.cpp b/src/util.cpp index f6d80f7..7fb43bc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -331,7 +331,7 @@ string vstrprintf(const char *format, va_list ap) if (p != buffer) delete[] p; limit *= 2; - p = new char[limit]; + p = new(nothrow) char[limit]; if (p == NULL) throw std::bad_alloc(); }