From 1b45a7f19dc38d9ec1b5f580e43e37dda892eb58 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Fri, 4 Mar 2016 23:19:59 +0300 Subject: [PATCH] Check for NULL values properly. --- src/db.cpp | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) 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: -- 1.7.1