From 55b7eeb4d371990db2c6a7f21165fac2e1b33ab1 Mon Sep 17 00:00:00 2001 From: ip_gpu Date: Mon, 30 Oct 2017 08:18:14 +0500 Subject: [PATCH 1/2] fixed from PVS-Studio: V668 There is no sense in testing the 'lpHashCheck' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. chashcheckclassfactory.cpp 39 --- CHashCheckClassFactory.cpp | 16 ++++++++++------ CHashCheckClassFactory.hpp | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHashCheckClassFactory.cpp b/CHashCheckClassFactory.cpp index 3403fa3..966bce6 100644 --- a/CHashCheckClassFactory.cpp +++ b/CHashCheckClassFactory.cpp @@ -35,10 +35,14 @@ STDMETHODIMP CHashCheckClassFactory::CreateInstance( LPUNKNOWN pUnkOuter, REFIID if (pUnkOuter) return(CLASS_E_NOAGGREGATION); - LPCHASHCHECK lpHashCheck = new CHashCheck; - if (lpHashCheck == NULL) return(E_OUTOFMEMORY); - - HRESULT hr = lpHashCheck->QueryInterface(riid, ppv); - lpHashCheck->Release(); - return(hr); + try { + LPCHASHCHECK lpHashCheck = new CHashCheck; + HRESULT hr = lpHashCheck->QueryInterface(riid, ppv); + lpHashCheck->Release(); + return(hr); + } + catch (std::bad_alloc& ba) + { + return(E_OUTOFMEMORY); + } } diff --git a/CHashCheckClassFactory.hpp b/CHashCheckClassFactory.hpp index 155a2cc..cc03533 100644 --- a/CHashCheckClassFactory.hpp +++ b/CHashCheckClassFactory.hpp @@ -10,6 +10,7 @@ #define __CHASHCHECKCLASSFACTORY_HPP__ #include "globals.h" +#include class CHashCheckClassFactory : public IClassFactory { From 9f3951ece0536fe35355b173978ce0dc6e5c082b Mon Sep 17 00:00:00 2001 From: ip_gpu Date: Mon, 30 Oct 2017 08:20:51 +0500 Subject: [PATCH 2/2] changed version --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index 1e447e1..61ef933 100644 --- a/version.h +++ b/version.h @@ -12,10 +12,10 @@ #define HASHCHECK_NAME_STR "HashCheck Shell Extension" // Full version: MUST be in the form of major,minor,revision,build -#define HASHCHECK_VERSION_FULL 2,4,0,55 +#define HASHCHECK_VERSION_FULL 2,4,0,56 // String version: May be any suitable string -#define HASHCHECK_VERSION_STR "2.4.0.55" +#define HASHCHECK_VERSION_STR "2.4.0.56" #ifdef _USRDLL // PE version: MUST be in the form of major.minor