diff options
author | George Hazan <ghazan@miranda.im> | 2020-05-10 17:16:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-05-10 17:16:55 +0300 |
commit | 013de96b8f9abbb082fac524ca0001fa112194f5 (patch) | |
tree | bfce955fe7b7131694a62102c0d484b2fc0a7f8d /protocols/VKontakte | |
parent | 728b55c7e6fc307f084caabfdaf6a89aa6cf4f1d (diff) |
VKontakte: fix for memory corruption in CVkAccMgrForm
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 89 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.h | 19 |
2 files changed, 50 insertions, 58 deletions
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index c1dc9e8113..38f8aac213 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -19,55 +19,66 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ////////////////////// Account manager dialog ////////////////////////////////
-INT_PTR CVkProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
+class CVkAccMgrForm : public CVkDlgBase
{
- CVkAccMgrForm *dlg = new CVkAccMgrForm(this, (HWND)lParam);
- dlg->Show();
- return (INT_PTR)dlg->GetHwnd();
-}
+ typedef CVkDlgBase CSuper;
-//////////////////////////////////////////////////////////////////////////////
+ CCtrlEdit m_edtLogin;
+ CCtrlEdit m_edtPassword;
+ CCtrlHyperlink m_hlLink;
-CVkAccMgrForm::CVkAccMgrForm(CVkProto *proto, HWND hwndParent) :
- CVkDlgBase(proto, IDD_ACCMGRUI),
- m_edtLogin(this, IDC_LOGIN),
- m_edtPassword(this, IDC_PASSWORD),
- m_hlLink(this, IDC_URL, "https://vk.com/")
-{
- SetParent(hwndParent);
+ pass_ptrW m_pwszOldPass;
+ ptrW m_pwszOldLogin;
- CreateLink(m_edtLogin, "Login", L"");
-}
+public:
+ CVkAccMgrForm(CVkProto *proto, HWND hwndParent) :
+ CVkDlgBase(proto, IDD_ACCMGRUI),
+ m_edtLogin(this, IDC_LOGIN),
+ m_edtPassword(this, IDC_PASSWORD),
+ m_hlLink(this, IDC_URL, "https://vk.com/")
+ {
+ SetParent(hwndParent);
-bool CVkAccMgrForm::OnInitDialog()
-{
- CSuper::OnInitDialog();
+ CreateLink(m_edtLogin, "Login", L"");
+ }
- m_pwszOldLogin = m_edtLogin.GetText();
- m_edtLogin.SendMsg(EM_LIMITTEXT, 1024, 0);
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
- m_pwszOldPass = m_proto->GetUserStoredPassword();
- m_edtPassword.SetText(m_pwszOldPass);
- m_edtPassword.SendMsg(EM_LIMITTEXT, 1024, 0);
- return true;
-}
+ m_pwszOldLogin = m_edtLogin.GetText();
+ m_edtLogin.SendMsg(EM_LIMITTEXT, 1024, 0);
-bool CVkAccMgrForm::OnApply()
-{
- pass_ptrW pwszNewPass(m_edtPassword.GetText());
- bool bPassChanged = mir_wstrcmp(m_pwszOldPass, pwszNewPass) != 0;
- if (bPassChanged) {
- T2Utf szRawPasswd(pwszNewPass);
- m_proto->setString("Password", szRawPasswd);
- pass_ptrA pszPass(szRawPasswd.detach());
- m_pwszOldPass = pwszNewPass;
+ m_pwszOldPass = m_proto->GetUserStoredPassword();
+ m_edtPassword.SetText(m_pwszOldPass);
+ m_edtPassword.SendMsg(EM_LIMITTEXT, 1024, 0);
+ return true;
}
- ptrW pwszNewLogin(m_edtLogin.GetText());
- if (bPassChanged || mir_wstrcmpi(m_pwszOldLogin, pwszNewLogin))
- m_proto->ClearAccessToken();
- m_pwszOldLogin = pwszNewLogin;
- return true;
+ bool OnApply() override
+ {
+ pass_ptrW pwszNewPass(m_edtPassword.GetText());
+ bool bPassChanged = mir_wstrcmp(m_pwszOldPass, pwszNewPass) != 0;
+ if (bPassChanged) {
+ T2Utf szRawPasswd(pwszNewPass);
+ m_proto->setString("Password", szRawPasswd);
+ pass_ptrA pszPass(szRawPasswd.detach());
+ m_pwszOldPass = pwszNewPass.detach();
+ }
+
+ ptrW pwszNewLogin(m_edtLogin.GetText());
+ if (bPassChanged || mir_wstrcmpi(m_pwszOldLogin, pwszNewLogin))
+ m_proto->ClearAccessToken();
+ m_pwszOldLogin = pwszNewLogin.detach();
+ return true;
+ }
+};
+
+INT_PTR CVkProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
+{
+ CVkAccMgrForm *dlg = new CVkAccMgrForm(this, (HWND)lParam);
+ dlg->Show();
+ return (INT_PTR)dlg->GetHwnd();
}
////////////////////// Options ///////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h index c467b1c437..2e277ba503 100644 --- a/protocols/VKontakte/src/vk_options.h +++ b/protocols/VKontakte/src/vk_options.h @@ -20,25 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. typedef CProtoDlgBase<CVkProto> CVkDlgBase;
-////////////////////// Account manager dialog ////////////////////////////////
-
-class CVkAccMgrForm : public CVkDlgBase
-{
- typedef CVkDlgBase CSuper;
-
- CCtrlEdit m_edtLogin;
- CCtrlEdit m_edtPassword;
- CCtrlHyperlink m_hlLink;
-
- pass_ptrW m_pwszOldPass;
- ptrW m_pwszOldLogin;
-
-public:
- CVkAccMgrForm(CVkProto *proto, HWND hwndParent);
- bool OnInitDialog() override;
- bool OnApply() override;
-};
-
////////////////////// Account page //////////////////////////////////////////
class CVkOptionAccountForm : public CVkDlgBase
|