diff options
author | sundb <sundbcn@gmail.com> | 2022-08-14 16:50:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-14 11:50:18 +0300 |
commit | 8aad2ac35201fd6feadb6f59e7cc0c2afb19129b (patch) | |
tree | ab68434de69aab23235f9cd739e7f31d4c5b8776 /src/eval.c | |
parent | 1f600efd013b9b01d683ba32f7630a5cf51ada43 (diff) | |
download | redis-8aad2ac35201fd6feadb6f59e7cc0c2afb19129b.tar.gz |
Add missing lua_pop in luaGetFromRegistry (#11097)
This pr mainly has the following four changes:
1. Add missing lua_pop in `luaGetFromRegistry`.
This bug affects `redis.register_function`, where `luaGetFromRegistry` in
`luaRegisterFunction` will return null when we call `redis.register_function` nested.
.e.g
```
FUNCTION LOAD "#!lua name=mylib \n local lib=redis \n lib.register_function('f2', function(keys, args) lib.register_function('f1', function () end) end)"
fcall f2 0
````
But since we exit when luaGetFromRegistry returns null, it does not cause the stack to grow indefinitely.
3. When getting `REGISTRY_RUN_CTX_NAME` from the registry, use `serverAssert`
instead of error return. Since none of these lua functions are registered at the time
of function load, scriptRunCtx will never be NULL.
4. Add `serverAssert` for `luaLdbLineHook`, `luaEngineLoadHook`.
5. Remove `luaGetFromRegistry` from `redis_math_random` and
`redis_math_randomseed`, it looks like they are redundant.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index e2ee41cb5..dd488a984 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1629,6 +1629,7 @@ ldbLog(sdsnew(" next line of code.")); * to start executing a new line. */ void luaLdbLineHook(lua_State *lua, lua_Debug *ar) { scriptRunCtx* rctx = luaGetFromRegistry(lua, REGISTRY_RUN_CTX_NAME); + serverAssert(rctx); /* Only supported inside script invocation */ lua_getstack(lua,0,ar); lua_getinfo(lua,"Sl",ar); ldb.currentline = ar->currentline; |