From f19cfb336150358214572a35ebe6c97c4975d6a0 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 9 Jul 2014 02:01:57 +0200 Subject: Static Code Analysis : Correctly initialize member variables in various constructors --- src/Common/BootEncryption.cpp | 7 +++++++ src/Common/BootEncryption.h | 2 +- src/Common/Exception.h | 4 ++-- src/Common/SecurityToken.h | 7 ++++--- 4 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 29df5569..1a467eed 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -375,6 +375,13 @@ namespace VeraCrypt SelectedEncryptionAlgorithmId (0), VolumeHeaderValid (false) { + HiddenOSCandidatePartition.IsGPT = FALSE; + HiddenOSCandidatePartition.Number = (size_t) -1; + DriveConfig.DriveNumber = -1; + DriveConfig.ExtraBootPartitionPresent = false; + DriveConfig.SystemLoaderPresent = false; + DriveConfig.InitialUnallocatedSpace = 0; + DriveConfig.TotalUnallocatedSpace = 0; Elevator::AddReference(); } diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h index 16e42e11..88830988 100644 --- a/src/Common/BootEncryption.h +++ b/src/Common/BootEncryption.h @@ -22,7 +22,7 @@ namespace VeraCrypt class File { public: - File () : FileOpen (false) { } + File () : Elevated (false), FileOpen (false), FilePointerPosition(0), Handle(NULL), IsDevice(false) { } File (string path, bool readOnly = false, bool create = false); ~File () { Close(); } diff --git a/src/Common/Exception.h b/src/Common/Exception.h index 5bf9395f..e034404b 100644 --- a/src/Common/Exception.h +++ b/src/Common/Exception.h @@ -35,12 +35,12 @@ namespace VeraCrypt struct ErrorException : public Exception { ErrorException (char *langId) : ErrLangId (langId) { } - ErrorException (const wstring &errMsg) : ErrMsg (errMsg) { } + ErrorException (const wstring &errMsg) : ErrLangId(NULL), ErrMsg (errMsg) { } void Show (HWND parent) const { if (ErrMsg.empty()) - ::Error (ErrLangId); + ::Error (ErrLangId? ErrLangId : ""); else ::ErrorDirect (ErrMsg.c_str()); } diff --git a/src/Common/SecurityToken.h b/src/Common/SecurityToken.h index c83ed328..8cad17c1 100644 --- a/src/Common/SecurityToken.h +++ b/src/Common/SecurityToken.h @@ -69,7 +69,7 @@ namespace VeraCrypt struct SecurityTokenKeyfile { - SecurityTokenKeyfile () { } + SecurityTokenKeyfile () : Handle(CK_INVALID_HANDLE), SlotId(CK_UNAVAILABLE_INFORMATION) { Token.SlotId = CK_UNAVAILABLE_INFORMATION; Token.Flags = 0; } SecurityTokenKeyfile (const SecurityTokenKeyfilePath &path); operator SecurityTokenKeyfilePath () const; @@ -85,7 +85,8 @@ namespace VeraCrypt { Pkcs11Exception (CK_RV errorCode = (CK_RV) -1) : ErrorCode (errorCode), - SubjectErrorCodeValid (false) + SubjectErrorCodeValid (false), + SubjectErrorCode( (uint64) -1) { } @@ -155,7 +156,7 @@ namespace VeraCrypt struct Pkcs11Session { - Pkcs11Session () : UserLoggedIn (false) { } + Pkcs11Session () : Handle (CK_UNAVAILABLE_INFORMATION), UserLoggedIn (false) { } CK_SESSION_HANDLE Handle; bool UserLoggedIn; -- cgit v1.2.3