From c019fc05d2a58bef6f006546d0300aaf39133f38 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 30 Sep 2009 21:58:46 +0200 Subject: [PATCH] do some checks on data fetched from last.fm while parsing it --- src/info.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index d61711d2..f8f65016 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -277,8 +277,21 @@ void *Info::PrepareArtist(void *screen_void_ptr) urls.push_back(result.substr(i, j-i)); } - a = result.find("")+static_strlen(""); - b = result.find(""); + bool parse_failed = 0; + if ((a = result.find("")) != std::string::npos) + { + a += static_strlen(""); + if ((b = result.find("")) == 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) {