mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
fix: JSON.ARRPOP command crash fixed (#5026)
fixed: https://github.com/dragonflydb/dragonfly/issues/5025
This commit is contained in:
parent
13d8062bb9
commit
84456a2442
2 changed files with 9 additions and 0 deletions
|
@ -1794,6 +1794,10 @@ void JsonFamily::ArrPop(CmdArgList args, const CommandContext& cmd_cntx) {
|
|||
int index = parser.NextOrDefault<int>(-1);
|
||||
|
||||
auto* builder = static_cast<RedisReplyBuilder*>(cmd_cntx.rb);
|
||||
if (auto err = parser.Error(); err) {
|
||||
return builder->SendError(err->MakeReply());
|
||||
}
|
||||
|
||||
WrappedJsonPath json_path = GET_OR_SEND_UNEXPECTED(ParseJsonPath(path));
|
||||
|
||||
auto cb = [&](Transaction* t, EngineShard* shard) {
|
||||
|
|
|
@ -3074,4 +3074,9 @@ TEST_F(JsonFamilyTest, SetNestedFields) {
|
|||
EXPECT_EQ(resp, R"({"-field2":2,"field1":1})");
|
||||
}
|
||||
|
||||
TEST_F(JsonFamilyTest, ArrPopWithFormatParameter) {
|
||||
auto resp = Run({"JSON.ARRPOP", "test_resp3", "FORMAT", "EXPAND", "$.a"});
|
||||
ASSERT_THAT(resp, ErrArg("value is not an integer or out of range"));
|
||||
}
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue