do some checks on data fetched from last.fm while parsing it

This commit is contained in:
Andrzej Rybczak
2009-09-30 21:58:46 +02:00
parent 884cb0b7fb
commit c019fc05d2

View File

@@ -277,8 +277,21 @@ void *Info::PrepareArtist(void *screen_void_ptr)
urls.push_back(result.substr(i, j-i)); urls.push_back(result.substr(i, j-i));
} }
a = result.find("<content>")+static_strlen("<content>"); bool parse_failed = 0;
b = result.find("</content>"); if ((a = result.find("<content>")) != std::string::npos)
{
a += static_strlen("<content>");
if ((b = result.find("</content>")) == std::string::npos)
parse_failed = 1;
}
else
parse_failed = 1;
if (parse_failed)
{
*screen->w << "Error: Fetched data could not be parsed";
ArtistReady = 1;
pthread_exit(0);
}
if (a == b) if (a == b)
{ {