Skip to content

Commit

Permalink
fix parser memeory leak (#3575)
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince authored Dec 28, 2021
1 parent 74464bf commit 7398d80
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/kvstore/raftex/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,8 @@ folly::Future<cpp2::AppendLogResponse> Host::sendAppendLogRequest(
return client->future_appendLog(*req);
}

folly::Future<cpp2::HeartbeatResponse> Host::sendHeartbeat(folly::EventBase* eb,
TermID term,
LogID commitLogId,
TermID lastLogTerm,
LogID lastLogId) {
folly::Future<cpp2::HeartbeatResponse> Host::sendHeartbeat(
folly::EventBase* eb, TermID term, LogID commitLogId, TermID lastLogTerm, LogID lastLogId) {
auto req = std::make_shared<cpp2::HeartbeatRequest>();
req->space_ref() = part_->spaceId();
req->part_ref() = part_->partitionId();
Expand Down
7 changes: 2 additions & 5 deletions src/kvstore/raftex/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ class Host final : public std::enable_shared_from_this<Host> {
TermID lastLogTermSent, // The last log term being sent
LogID lastLogIdSent); // The last log id being sent

folly::Future<cpp2::HeartbeatResponse> sendHeartbeat(folly::EventBase* eb,
TermID term,
LogID commitLogId,
TermID lastLogTerm,
LogID lastLogId);
folly::Future<cpp2::HeartbeatResponse> sendHeartbeat(
folly::EventBase* eb, TermID term, LogID commitLogId, TermID lastLogTerm, LogID lastLogId);

const HostAddr& address() const {
return addr_;
Expand Down
3 changes: 3 additions & 0 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -2597,6 +2597,7 @@ index_field
}
| name_label L_PAREN INTEGER R_PAREN {
if ($3 > std::numeric_limits<int16_t>::max()) {
delete $1;
throw nebula::GraphParser::syntax_error(@3, "Out of range:");
}
$$ = new meta::cpp2::IndexFieldDef();
Expand Down Expand Up @@ -2905,6 +2906,8 @@ match_sentences
assignment_sentence
: VARIABLE ASSIGN set_sentence {
if (qctx->existParameter(*$1)) {
delete $1;
delete $3;
throw nebula::GraphParser::syntax_error(@1, "Variable definition conflicts with a parameter");
} else {
$$ = new AssignmentSentence($1, $3);
Expand Down
15 changes: 15 additions & 0 deletions src/parser/test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3260,6 +3260,21 @@ TEST_F(ParserTest, DetectMemoryLeakTest) {
ASSERT_EQ(result.value()->toString(),
"YIELD reduce(totalNum = 10, n IN range(1,3) | (totalNum+n))");
}
{
std::string query = "CREATE TAG INDEX IF NOT EXISTS std_index ON t1(c1(4294967296), c2)";
auto result = parse(query);
ASSERT_FALSE(result.ok()) << result.status();
ASSERT_EQ(result.status().toString(), "SyntaxError: Out of range: near `4294967296'");
}
{
std::string query = "$param = GO FROM 'Tony Parker' over like YIELD like._dst AS vv";
auto* ectx = qctx_->ectx();
ectx->setValue("param", "TestData");
auto result = parse(query);
ASSERT_FALSE(result.ok()) << result.status();
ASSERT_EQ(result.status().toString(),
"SyntaxError: Variable definition conflicts with a parameter near `$param'");
}
}

TEST_F(ParserTest, TestNameLabel) {
Expand Down

0 comments on commit 7398d80

Please sign in to comment.