Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ce81ee

Browse files
authored
Fix web service crash(issue:vesoft-inc#4398) (vesoft-inc#4405)
* when we use flags put interface, but we does not specify the body. * The service will be crashed. For example: curl -X PUT xxx.xxx.xxx.xxxx:19559/flags
1 parent d53486c commit 7ce81ee

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/webservice/SetFlagsHandler.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ void SetFlagsHandler::onBody(std::unique_ptr<folly::IOBuf> body) noexcept {
3939
void SetFlagsHandler::onEOM() noexcept {
4040
folly::dynamic flags;
4141
try {
42-
std::string body = body_->moveToFbString().toStdString();
43-
flags = folly::parseJson(body);
44-
if (flags.empty()) {
42+
if (!body_) {
43+
LOG(ERROR) << "Got an empty body";
4544
err_ = HttpCode::E_UNPROCESSABLE;
45+
} else {
46+
std::string body = body_->moveToFbString().toStdString();
47+
flags = folly::parseJson(body);
48+
if (flags.empty()) {
49+
err_ = HttpCode::E_UNPROCESSABLE;
50+
}
4651
}
4752
} catch (const std::exception &e) {
4853
LOG(ERROR) << "Fail to update flags: " << e.what();

0 commit comments

Comments
 (0)