From b808dcd6e35a8c3985428ba6385d760d117fa6cb Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Fri, 30 Jun 2017 19:13:51 +0200 Subject: [PATCH] Check that list is not empty before accessing it I've seen crash reports for this, but according to the logic in LogDlg it should not be possible as the OK button is disabled as long as nothing is selected. Signed-off-by: Sven Strickroth --- src/TortoiseProc/BisectStartDlg.cpp | 4 ++-- src/TortoiseProc/ChooseVersion.h | 2 +- src/TortoiseProc/CommitDlg.cpp | 4 ++-- src/TortoiseProc/FormatPatchDlg.cpp | 4 ++-- src/TortoiseProc/PushDlg.cpp | 2 +- src/TortoiseProc/RebaseDlg.cpp | 2 +- src/TortoiseProc/RepositoryBrowser.cpp | 2 +- src/TortoiseProc/RequestPullDlg.cpp | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/TortoiseProc/BisectStartDlg.cpp b/src/TortoiseProc/BisectStartDlg.cpp index c12978914..7d1024265 100644 --- a/src/TortoiseProc/BisectStartDlg.cpp +++ b/src/TortoiseProc/BisectStartDlg.cpp @@ -152,7 +152,7 @@ void CBisectStartDlg::OnBnClickedButtonGood() dlg.ShowWorkingTreeChanges(false); // only one revision must be selected however dlg.SingleSelection(true); - if (dlg.DoModal() == IDOK) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { m_cLastGoodRevision.SetWindowText(dlg.GetSelectedHash().at(0).ToString()); OnChangedRevision(); @@ -171,7 +171,7 @@ void CBisectStartDlg::OnBnClickedButtonBad() dlg.ShowWorkingTreeChanges(false); // only one revision must be selected however dlg.SingleSelection(true); - if (dlg.DoModal() == IDOK) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { m_cFirstBadRevision.SetWindowText(dlg.GetSelectedHash().at(0).ToString()); OnChangedRevision(); diff --git a/src/TortoiseProc/ChooseVersion.h b/src/TortoiseProc/ChooseVersion.h index 543925682..1e4edc0c5 100644 --- a/src/TortoiseProc/ChooseVersion.h +++ b/src/TortoiseProc/ChooseVersion.h @@ -96,7 +96,7 @@ protected: dlg.ShowWorkingTreeChanges(false); // only one revision must be selected however dlg.SingleSelection(true); - if ( dlg.DoModal() == IDOK ) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { m_ChooseVersioinVersion.SetWindowText(dlg.GetSelectedHash().at(0).ToString()); OnVersionChanged(); diff --git a/src/TortoiseProc/CommitDlg.cpp b/src/TortoiseProc/CommitDlg.cpp index 32aafa65b..82fa32c1b 100644 --- a/src/TortoiseProc/CommitDlg.cpp +++ b/src/TortoiseProc/CommitDlg.cpp @@ -2051,7 +2051,7 @@ bool CCommitDlg::HandleMenuItemClick(int cmd, CSciEdit * pSciEdit) // only one revision must be selected however dlg.SingleSelection(true); dlg.ShowWorkingTreeChanges(false); - if (dlg.DoModal() == IDOK) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) pSciEdit->InsertText(dlg.GetSelectedHash().at(0).ToString()); return true; } @@ -2065,7 +2065,7 @@ bool CCommitDlg::HandleMenuItemClick(int cmd, CSciEdit * pSciEdit) // only one revision must be selected however dlg.SingleSelection(true); dlg.ShowWorkingTreeChanges(false); - if (dlg.DoModal() == IDOK) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { GitRev rev; if (rev.GetCommit(dlg.GetSelectedHash().at(0).ToString())) diff --git a/src/TortoiseProc/FormatPatchDlg.cpp b/src/TortoiseProc/FormatPatchDlg.cpp index 645c4d287..1288ca9e0 100644 --- a/src/TortoiseProc/FormatPatchDlg.cpp +++ b/src/TortoiseProc/FormatPatchDlg.cpp @@ -187,7 +187,7 @@ void CFormatPatchDlg::OnBnClickedButtonFrom() dlg.ShowWorkingTreeChanges(false); // only one revision must be selected however dlg.SingleSelection(true); - if ( dlg.DoModal() == IDOK ) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { m_cFrom.AddString(dlg.GetSelectedHash().at(0).ToString()); CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE); @@ -205,7 +205,7 @@ void CFormatPatchDlg::OnBnClickedButtonTo() dlg.SetSelect(true); // only one revision must be selected however dlg.SingleSelection(true); - if ( dlg.DoModal() == IDOK ) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { m_cTo.AddString(dlg.GetSelectedHash().at(0).ToString()); CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE); diff --git a/src/TortoiseProc/PushDlg.cpp b/src/TortoiseProc/PushDlg.cpp index c7e6e6b03..19f46aa67 100644 --- a/src/TortoiseProc/PushDlg.cpp +++ b/src/TortoiseProc/PushDlg.cpp @@ -484,7 +484,7 @@ void CPushDlg::OnBnClickedButtonBrowseSourceBranch() dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0); dlg.SetSelect(true); dlg.ShowWorkingTreeChanges(false); - if(dlg.DoModal() == IDOK) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { m_BranchSource.SetWindowText(dlg.GetSelectedHash().at(0).ToString()); OnCbnSelchangeBranchSource(); diff --git a/src/TortoiseProc/RebaseDlg.cpp b/src/TortoiseProc/RebaseDlg.cpp index 76bcee46c..50185f92c 100644 --- a/src/TortoiseProc/RebaseDlg.cpp +++ b/src/TortoiseProc/RebaseDlg.cpp @@ -2817,7 +2817,7 @@ void CRebaseDlg::OnBnClickedButtonAdd() dlg.SetSelect(true); // allow multi-select dlg.SingleSelection(false); - if (dlg.DoModal() != IDOK) + if (dlg.DoModal() != IDOK || dlg.GetSelectedHash().empty()) return; auto selectedHashes = dlg.GetSelectedHash(); diff --git a/src/TortoiseProc/RepositoryBrowser.cpp b/src/TortoiseProc/RepositoryBrowser.cpp index de72b6b93..d5247eeef 100644 --- a/src/TortoiseProc/RepositoryBrowser.cpp +++ b/src/TortoiseProc/RepositoryBrowser.cpp @@ -961,7 +961,7 @@ void CRepositoryBrowser::OnBnClickedButtonRevision() dlg.ShowWorkingTreeChanges(false); // only one revision must be selected however dlg.SingleSelection(true); - if (dlg.DoModal() == IDOK) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) { m_sRevision = dlg.GetSelectedHash().at(0).ToString(); Refresh(); diff --git a/src/TortoiseProc/RequestPullDlg.cpp b/src/TortoiseProc/RequestPullDlg.cpp index 70f69d82b..a9021885a 100644 --- a/src/TortoiseProc/RequestPullDlg.cpp +++ b/src/TortoiseProc/RequestPullDlg.cpp @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2011-2014, 2016 - TortoiseGit +// Copyright (C) 2011-2014, 2016-2017 - TortoiseGit // with code of PullFetchDlg.cpp @@ -149,6 +149,6 @@ void CRequestPullDlg::OnBnClickedButtonLocalBranch() dlg.ShowWorkingTreeChanges(false); // only one revision must be selected however dlg.SingleSelection(true); - if ( dlg.DoModal() == IDOK ) + if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty()) m_cStartRevision.SetWindowText(dlg.GetSelectedHash().at(0).ToString()); } -- 2.11.4.GIT