fix(lua): Avoid infinite loop and fix sha compatibility with redis.

Fixes #146 and fixes #147.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2022-06-13 23:32:19 +03:00
parent f24005407b
commit c23dc1c94c
4 changed files with 18 additions and 9 deletions

View file

@ -53,10 +53,12 @@ void ScriptMgr::Run(CmdArgList args, ConnectionContext* cntx) {
if (subcmd == "LOAD" && args.size() == 2) {
string_view body = ArgS(args, 1);
body = absl::StripAsciiWhitespace(body);
if (body.empty())
return (*cntx)->SendError("Refuse to load empty script");
if (body.empty()) {
char sha[41];
Interpreter::FuncSha1(body, sha);
return (*cntx)->SendBulkString(sha);
}
Interpreter& interpreter = ServerState::tlocal()->GetInterpreter();
// no need to lock the interpreter since we do not mess the stack.