]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix off by one error in wxFTP::GetFileSize().
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Apr 2010 12:08:16 +0000 (12:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Apr 2010 12:08:16 +0000 (12:08 +0000)
We incremented the index once more even after finding the line we were looking
for in the array which meant that we accessed a wrong array element in any
case and could even attempt to access an out of bound one if the file was
found in the last line.

Closes #11964.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64105 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/ftp.cpp

index 519d7c561838f4c4cb5d02fdd9f1f6313fd00622..b1761ba38720d77ae9135a885f6f10ffa67d0666 100644 (file)
@@ -960,15 +960,15 @@ int wxFTP::GetFileSize(const wxString& fileName)
                     // substring containing the name we are looking for. We
                     // stop the iteration at the first occurrence of the
                     // filename. The search is not case-sensitive.
-                    bool foundIt = false;
-
+                    const size_t numFiles = fileList.size();
                     size_t i;
-                    for ( i = 0; !foundIt && i < fileList.GetCount(); i++ )
+                    for ( i = 0; i < fileList.GetCount(); i++ )
                     {
-                        foundIt = fileList[i].Upper().Contains(fileName.Upper());
+                        if ( fileList[i].Upper().Contains(fileName.Upper()) )
+                            break;
                     }
 
-                    if ( foundIt )
+                    if ( i != numFiles )
                     {
                         // The index i points to the first occurrence of
                         // fileName in the array Now we have to find out what