From ea259cfa388e91c403474554d503bc920caa8003 Mon Sep 17 00:00:00 2001 From: Perry Rapp Date: Wed, 1 Jun 2005 20:46:48 +0000 Subject: [PATCH] 2005-06-01 Perry Add commenting & array bounds checking to CMergeApp::LoadProjectFile Src: Merge.cpp --- Src/Merge.cpp | 14 ++++++++++++++ Src/readme.txt | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/Src/Merge.cpp b/Src/Merge.cpp index a6be810b1..36a383fe6 100644 --- a/Src/Merge.cpp +++ b/Src/Merge.cpp @@ -775,6 +775,9 @@ void CAboutDlg::OnBnClickedOpenContributors() /** * @brief Read paths and filter from project file. + * + * Tries to find project file in files[0] and files[1] by extension + * If cannot find one, returns FALSE */ BOOL CMergeApp::LoadProjectFile(CStringArray & files, BOOL & recursive) { @@ -784,11 +787,20 @@ BOOL CMergeApp::LoadProjectFile(CStringArray & files, BOOL & recursive) CString ProjectFileName; CString ext; + // Look for project file in files[0] and files[1] + + if (files.GetSize() < 2) + return FALSE; // code further down assumes files[0] and files[1] exist + SplitFilename(files[0], NULL, NULL, &ext); if (ext == PROJECTFILE_EXT) + { ProjectFileName = files[0]; + } else { + if (files.GetSize() == 1) + return FALSE; SplitFilename(files[1], NULL, NULL, &ext); if (ext == PROJECTFILE_EXT) ProjectFileName = files[1]; @@ -796,6 +808,8 @@ BOOL CMergeApp::LoadProjectFile(CStringArray & files, BOOL & recursive) return FALSE; } + // We found project file, and stored it in ProjectFileName + if (!ProjectFileName.IsEmpty()) { if (!pfile.Read(ProjectFileName, &err)) diff --git a/Src/readme.txt b/Src/readme.txt index e73a8e91a..5bc59f2ad 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2005-06-01 Perry + Add commenting & array bounds checking to CMergeApp::LoadProjectFile + Src: Merge.cpp + 2005-06-01 Kimmo PATCH: [ 1210059 ] Sanity check difference before merging it Src: Merge.rc MergeDoc.cpp MergeDoc.h resource.h -- 2.11.0