Skip to content

Commit

Permalink
fix(AliNLS): crash when refresh token error.
Browse files Browse the repository at this point in the history
We haven't deal with Ali API return error to us, so get data from
json cause program crash.

Signed-off-by: Hakusai Zhang <xm1994@gmail.com>
  • Loading branch information
summershrimp committed Apr 14, 2024
1 parent 94fb957 commit d7f3e5f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/builder/ASR/AliNLSBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,17 @@ void AliNLSBuilder::refreshToken()
QJsonObject jsonObject =
QJsonDocument::fromJson(QByteArray::fromStdString(resp.text))
.object();
token = jsonObject.find("Token")
.value()
.toObject()
.find("Id")
.value()
.toString();
auto tokenIter = jsonObject.find("Token");
if (tokenIter == jsonObject.end()) {
token = "";
blog(LOG_WARNING, "Token error, resp: %s", resp.text.c_str());
} else {
token = tokenIter.value()
.toObject()
.find("Id")
.value()
.toString();
}
qDebug() << "Token:" << token;
needRefresh = false;
}
Expand Down

0 comments on commit d7f3e5f

Please sign in to comment.