Fix use of invalid find iterator in wxMemoryFSHandler

Calling FindFirst() with an URL without wildcards returned the correct
result, but didn't reset m_findIter, which kept its value from the
previous search that could have been invalidated since then, e.g. if
RemoveFile() has been called. Using this value could result in a crash
during the next call to FindNext().

Fix this by ensuring that we always reset m_findIter to the valid (even
if pointing to the end) value as the first thing we do in FindFirst().

Closes #18744.
This commit is contained in:
Ben Bronk
2020-05-01 15:40:43 +02:00
committed by Vadim Zeitlin
parent a973d02c9f
commit 10ee1b8d10

View File

@@ -123,6 +123,10 @@ wxFSFile * wxMemoryFSHandlerBase::OpenFile(wxFileSystem& WXUNUSED(fs),
wxString wxMemoryFSHandlerBase::FindFirst(const wxString& url, int flags)
{
// Make sure to reset the find iterator, so that calling FindNext() doesn't
// reuse its value from the last search that could well be invalid.
m_findIter = m_Hash.end();
if ( (flags & wxDIR) && !(flags & wxFILE) )
{
// we only store files, not directories, so we don't risk finding