From: Vadim Zeitlin Date: Thu, 22 Apr 2010 12:08:16 +0000 (+0000) Subject: Fix off by one error in wxFTP::GetFileSize(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a96160b58fb552c445de9569c0a891a8a15ab239 Fix off by one error in wxFTP::GetFileSize(). 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 --- diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 519d7c5618..b1761ba387 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -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