Skip to content

Commit

Permalink
check return values.
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed Apr 12, 2015
1 parent f3db7b6 commit 927baac
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/StelJsonParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ QByteArray StelJsonParserInstance::readString()
return name;
case '\\':
{
getChar(&c);
bool gotChar=getChar(&c);
if (!gotChar) {qWarning() << "cannot read further, error?"; continue;}
if (c=='b') c='\b';
if (c=='f') c='\f';
if (c=='n') c='\n';
Expand Down Expand Up @@ -278,8 +279,8 @@ QVariant StelJsonParserInstance::parse()
if (!skipAndConsumeChar('\"'))
{
char cc=0;
getChar(&cc);
throw std::runtime_error(qPrintable(QString("Expected '\"' at beginning of string, found: '%1' (ASCII %2)").arg(cc).arg((int)(cc))));
if (getChar(&cc))
throw std::runtime_error(qPrintable(QString("Expected '\"' at beginning of string, found: '%1' (ASCII %2)").arg(cc).arg((int)(cc))));
}
const QByteArray& ar = readString();
const QString& key = QString::fromUtf8(ar.constData(), ar.size());
Expand Down

0 comments on commit 927baac

Please sign in to comment.