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
This commit is contained in:
@@ -960,15 +960,15 @@ int wxFTP::GetFileSize(const wxString& fileName)
|
|||||||
// substring containing the name we are looking for. We
|
// substring containing the name we are looking for. We
|
||||||
// stop the iteration at the first occurrence of the
|
// stop the iteration at the first occurrence of the
|
||||||
// filename. The search is not case-sensitive.
|
// filename. The search is not case-sensitive.
|
||||||
bool foundIt = false;
|
const size_t numFiles = fileList.size();
|
||||||
|
|
||||||
size_t i;
|
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
|
// The index i points to the first occurrence of
|
||||||
// fileName in the array Now we have to find out what
|
// fileName in the array Now we have to find out what
|
||||||
|
Reference in New Issue
Block a user