1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-15 10:48:33 +01:00

Don't return a free'd pointer from Echonest::ParseError::what(). Might fix a crash on Windows when there are no echonest results.

This commit is contained in:
David Sansome 2013-09-07 15:39:05 +10:00
parent d3295f083b
commit 4ec7c09522
2 changed files with 28 additions and 19 deletions

View File

@ -45,34 +45,21 @@ QUrl Echonest::baseGetQuery(const QByteArray& type, const QByteArray& method)
Echonest::ParseError::ParseError(Echonest::ErrorType error): exception()
{
type = error;
whatData = createWhatData();
}
Echonest::ParseError::ParseError(Echonest::ErrorType error, const QString& text): exception()
{
type = error;
extraText = text;
whatData = createWhatData();
}
Echonest::ParseError::~ParseError() throw()
{}
Echonest::ErrorType Echonest::ParseError::errorType() const throw()
QByteArray Echonest::ParseError::createWhatData() const throw()
{
return type;
}
void Echonest::ParseError::setNetworkError( QNetworkReply::NetworkError error ) throw()
{
nError = error;
}
const char* Echonest::ParseError::what() const throw()
{
// If we have specific error text, return that first
// If we have specific error text, use that first
if( !extraText.isEmpty() )
return extraText.toLatin1().constData();
return extraText.toLatin1();
switch( type )
{
@ -99,7 +86,26 @@ const char* Echonest::ParseError::what() const throw()
case UnknownParseError:
return "Unknown Parse Error";
}
return "";
return QByteArray();
}
Echonest::ParseError::~ParseError() throw()
{}
Echonest::ErrorType Echonest::ParseError::errorType() const throw()
{
return type;
}
void Echonest::ParseError::setNetworkError( QNetworkReply::NetworkError error ) throw()
{
nError = error;
}
const char* Echonest::ParseError::what() const throw()
{
return whatData.constData();
}

View File

@ -74,9 +74,12 @@ namespace Echonest{
virtual const char* what() const throw ();
private:
QByteArray createWhatData() const throw();
ErrorType type;
QString extraText;
QNetworkReply::NetworkError nError;
QByteArray whatData;
};
class ConfigPrivate;