diff --git a/src/Main/Forms/WaitDialog.cpp b/src/Main/Forms/WaitDialog.cpp index f9fc53b0..9d233e1f 100644 --- a/src/Main/Forms/WaitDialog.cpp +++ b/src/Main/Forms/WaitDialog.cpp @@ -33,12 +33,13 @@ namespace VeraCrypt void WaitDialog::ThrowException(Exception* ex) { #define VC_CONVERT_EXCEPTION(NAME) if (dynamic_cast (ex)) throw (NAME&) *ex; - VC_CONVERT_EXCEPTION (PasswordIncorrect); + // Handle PasswordIncorrect subclasses before the base class to avoid slicing. VC_CONVERT_EXCEPTION (PasswordKeyfilesIncorrect); VC_CONVERT_EXCEPTION (PasswordOrKeyboardLayoutIncorrect); VC_CONVERT_EXCEPTION (PasswordOrMountOptionsIncorrect); VC_CONVERT_EXCEPTION (ProtectionPasswordIncorrect); VC_CONVERT_EXCEPTION (ProtectionPasswordKeyfilesIncorrect); + VC_CONVERT_EXCEPTION (PasswordIncorrect); VC_CONVERT_EXCEPTION (PasswordEmpty); VC_CONVERT_EXCEPTION (PasswordTooLong); VC_CONVERT_EXCEPTION (PasswordUTF8TooLong); diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp index 8ea98fb6..2a5fd71a 100644 --- a/src/Main/UserInterface.cpp +++ b/src/Main/UserInterface.cpp @@ -1872,12 +1872,13 @@ const FileManager fileManagers[] = { void UserInterface::ThrowException (Exception* ex) { - VC_CONVERT_EXCEPTION (PasswordIncorrect); + // Handle PasswordIncorrect subclasses before the base class to avoid slicing. VC_CONVERT_EXCEPTION (PasswordKeyfilesIncorrect); VC_CONVERT_EXCEPTION (PasswordOrKeyboardLayoutIncorrect); VC_CONVERT_EXCEPTION (PasswordOrMountOptionsIncorrect); VC_CONVERT_EXCEPTION (ProtectionPasswordIncorrect); VC_CONVERT_EXCEPTION (ProtectionPasswordKeyfilesIncorrect); + VC_CONVERT_EXCEPTION (PasswordIncorrect); VC_CONVERT_EXCEPTION (PasswordEmpty); VC_CONVERT_EXCEPTION (PasswordTooLong); VC_CONVERT_EXCEPTION (PasswordUTF8TooLong);