From: CryptoManiac Date: Fri, 4 Mar 2016 20:19:59 +0000 (+0300) Subject: Check for NULL values properly. X-Git-Tag: nvc-v0.5.6~36 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=1b45a7f19dc38d9ec1b5f580e43e37dda892eb58 Check for NULL values properly. --- diff --git a/src/db.cpp b/src/db.cpp index 757a18e..68d19fe 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -397,7 +397,6 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) Dbc* pcursor = db.GetCursor(); if (pcursor) { - size_t pszSkipLen = strlen(pszSkip); while (fSuccess) { CDataStream ssKey(SER_DISK, CLIENT_VERSION); @@ -414,9 +413,14 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) fSuccess = false; break; } - if (pszSkip && - strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), pszSkipLen)) == 0) - continue; + + if (pszSkip != NULL) + { + size_t pszSkipLen = strlen(pszSkip); + if (strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), pszSkipLen)) == 0) + continue; + } + if (strncmp(&ssKey[0], "\x07version", 8) == 0) { // Update version: