From: Frank Li Date: Sun, 26 Jul 2009 13:36:15 +0000 (+0800) Subject: Fixed issue #122: Garbage text in "Git Command Progress" / suspected buffer overflow X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=895f2737e78460c3183f0bb6511459ba8fe2ece6;p=tortoisegit%2FTortoiseGitJp.git Fixed issue #122: Garbage text in "Git Command Progress" / suspected buffer overflow Improve commit speed when many added files. Signed-off-by: Frank Li --- diff --git a/src/TortoiseProc/CommitDlg.cpp b/src/TortoiseProc/CommitDlg.cpp index 97bb3b8..68e48c4 100644 --- a/src/TortoiseProc/CommitDlg.cpp +++ b/src/TortoiseProc/CommitDlg.cpp @@ -509,6 +509,7 @@ void CCommitDlg::OnOK() cmd.Format(_T("git.exe commit %s -F \"%s\""),amend, tempfile); CProgressDlg progress; + progress.m_bBufferAll=true; // improve show speed when there are many file added. progress.m_GitCmd=cmd; progress.m_bShowCommand = FALSE; // don't show the commit command progress.m_PreText = out; // show any output already generated in log window diff --git a/src/TortoiseProc/ProgressDlg.cpp b/src/TortoiseProc/ProgressDlg.cpp index 66909ca..3d98d3c 100644 --- a/src/TortoiseProc/ProgressDlg.cpp +++ b/src/TortoiseProc/ProgressDlg.cpp @@ -15,6 +15,7 @@ CProgressDlg::CProgressDlg(CWnd* pParent /*=NULL*/) { m_pThread = NULL; m_bAltAbortPress=false; + m_bBufferAll=false; } CProgressDlg::~CProgressDlg() @@ -196,6 +197,12 @@ LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam) } if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED) { + if(m_bBufferAll) + { + m_Databuf.push_back(0); + InsertCRLF(); + m_Log.SetWindowText(&m_Databuf[0]); + } m_BufStart=0; this->m_Databuf.clear(); @@ -224,16 +231,18 @@ LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam) DialogEnableWindow(IDCANCEL, FALSE); } - if(lParam == 0) + if(!m_bBufferAll) { - for(int i=this->m_BufStart;im_Databuf.size();i++) + if(lParam == 0) { - ParserCmdOutput(this->m_Databuf[m_BufStart]); - m_BufStart++; - } - }else - ParserCmdOutput((TCHAR)lParam); - + for(int i=this->m_BufStart;im_Databuf.size();i++) + { + ParserCmdOutput(this->m_Databuf[m_BufStart]); + m_BufStart++; + } + }else + ParserCmdOutput((TCHAR)lParam); + } return 0; } @@ -325,3 +334,18 @@ void CProgressDlg::OnCancel() m_bAbort = true; } + +void CProgressDlg::InsertCRLF() +{ + for(int i=0;i m_Databuf; int m_BufStart; + void InsertCRLF(); //Insert \r before \n + DECLARE_MESSAGE_MAP() public: