Skip to content

Commit

Permalink
Fix a segfault in mythweather when search for location
Browse files Browse the repository at this point in the history
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.
(cherry picked from commit f5d1986)
  • Loading branch information
stuartm committed Jul 16, 2012
1 parent 2384a3c commit 60fbb3c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions mythplugins/mythweather/mythweather/weatherSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,14 +1013,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);
Expand Down

0 comments on commit 60fbb3c

Please sign in to comment.