OSDN Git Service

2005-06-01 Perry
authorPerry Rapp <elsapo@users.sourceforge.net>
Wed, 1 Jun 2005 20:46:48 +0000 (20:46 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Wed, 1 Jun 2005 20:46:48 +0000 (20:46 +0000)
 Add commenting & array bounds checking to CMergeApp::LoadProjectFile
  Src: Merge.cpp

Src/Merge.cpp
Src/readme.txt

index a6be810..36a383f 100644 (file)
@@ -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))
index e73a8e9..5bc59f2 100644 (file)
@@ -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