Static Code Analysis : Correctly initialize member variables in various constructors

This commit is contained in:
Mounir IDRASSI 2014-07-09 02:01:57 +02:00
parent 9bb962c8bb
commit f19cfb3361
4 changed files with 14 additions and 6 deletions

View File

@ -375,6 +375,13 @@ namespace VeraCrypt
SelectedEncryptionAlgorithmId (0), SelectedEncryptionAlgorithmId (0),
VolumeHeaderValid (false) 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(); Elevator::AddReference();
} }

View File

@ -22,7 +22,7 @@ namespace VeraCrypt
class File class File
{ {
public: 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 (string path, bool readOnly = false, bool create = false);
~File () { Close(); } ~File () { Close(); }

View File

@ -35,12 +35,12 @@ namespace VeraCrypt
struct ErrorException : public Exception struct ErrorException : public Exception
{ {
ErrorException (char *langId) : ErrLangId (langId) { } ErrorException (char *langId) : ErrLangId (langId) { }
ErrorException (const wstring &errMsg) : ErrMsg (errMsg) { } ErrorException (const wstring &errMsg) : ErrLangId(NULL), ErrMsg (errMsg) { }
void Show (HWND parent) const void Show (HWND parent) const
{ {
if (ErrMsg.empty()) if (ErrMsg.empty())
::Error (ErrLangId); ::Error (ErrLangId? ErrLangId : "");
else else
::ErrorDirect (ErrMsg.c_str()); ::ErrorDirect (ErrMsg.c_str());
} }

View File

@ -69,7 +69,7 @@ namespace VeraCrypt
struct SecurityTokenKeyfile struct SecurityTokenKeyfile
{ {
SecurityTokenKeyfile () { } SecurityTokenKeyfile () : Handle(CK_INVALID_HANDLE), SlotId(CK_UNAVAILABLE_INFORMATION) { Token.SlotId = CK_UNAVAILABLE_INFORMATION; Token.Flags = 0; }
SecurityTokenKeyfile (const SecurityTokenKeyfilePath &path); SecurityTokenKeyfile (const SecurityTokenKeyfilePath &path);
operator SecurityTokenKeyfilePath () const; operator SecurityTokenKeyfilePath () const;
@ -85,7 +85,8 @@ namespace VeraCrypt
{ {
Pkcs11Exception (CK_RV errorCode = (CK_RV) -1) Pkcs11Exception (CK_RV errorCode = (CK_RV) -1)
: ErrorCode (errorCode), : ErrorCode (errorCode),
SubjectErrorCodeValid (false) SubjectErrorCodeValid (false),
SubjectErrorCode( (uint64) -1)
{ {
} }
@ -155,7 +156,7 @@ namespace VeraCrypt
struct Pkcs11Session struct Pkcs11Session
{ {
Pkcs11Session () : UserLoggedIn (false) { } Pkcs11Session () : Handle (CK_UNAVAILABLE_INFORMATION), UserLoggedIn (false) { }
CK_SESSION_HANDLE Handle; CK_SESSION_HANDLE Handle;
bool UserLoggedIn; bool UserLoggedIn;