Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a segfault in mythweather when search for location

If a script returned invalid data we would segfault because no bounds
checking was performed.

While here I refactored the loops immediately around the problem to
use proper iterators for speed and simplicity.
  • Loading branch information...
commit f5d1986f145d1992dde07561a781a94ac45f807b 1 parent 451cd30
@stuartm stuartm authored
Showing with 15 additions and 5 deletions.
  1. +15 −5 mythplugins/mythweather/mythweather/weatherSetup.cpp
View
20 mythplugins/mythweather/mythweather/weatherSetup.cpp
@@ -1020,14 +1020,24 @@ void LocationDialog::doSearch()
}
}
- for (int i = 0; i < result_cache.keys().size(); ++i)
+ QMap<ScriptInfo *, QStringList>::iterator it;
+ for (it = result_cache.begin(); it != result_cache.end(); ++it)
{
- si = result_cache.keys()[i];
- QStringList results = result_cache[si];
+ si = it.key();
+ QStringList results = it.value();
QString name = si->name;
- for (int ii = 0; ii < results.size(); ++ii)
+ QStringList::iterator rit;
+ for (rit = results.begin(); rit != results.end(); ++rit)
{
- QStringList tmp = results[ii].split("::");
+ QStringList tmp = (*rit).split("::");
+ if (tmp.size < 2)
+ {
+ LOG(VB_GENERAL, LOG_WARNING,
+ QString("Invalid line in Location Search reponse "
+ "from %1: %2")
+ .arg(name).arg(*rit));
+ continue;
+ }
QString resultstring = QString("%1 (%2)").arg(tmp[1]).arg(name);
MythUIButtonListItem *item =
new MythUIButtonListItem(m_locationList, resultstring);
Please sign in to comment.
Something went wrong with that request. Please try again.