From: Timo Sirainen Date: Fri, 10 Sep 2021 12:47:47 +0000 (+0300) Subject: dict-lua: Change dict:lookup() to actually return nil if key isn't found X-Git-Tag: 2.3.17~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39f2166fac34e713bf51a60785a631be1cf4d958;p=thirdparty%2Fdovecot%2Fcore.git dict-lua: Change dict:lookup() to actually return nil if key isn't found It was previously returning an empty table, although the comment said it should have returned nil. --- diff --git a/src/lib-dict/dict-lua.c b/src/lib-dict/dict-lua.c index 1be6b61fa4..abab8c7f93 100644 --- a/src/lib-dict/dict-lua.c +++ b/src/lib-dict/dict-lua.c @@ -27,11 +27,11 @@ static int lua_dict_async_continue(lua_State *L, lua_KContext ctx ATTR_UNUSED) { /* - * lua_dict_*_callback() already pushed the result table or error + * lua_dict_*_callback() already pushed the result table/nil or error * string. We simply need to return/error out. */ - if (lua_istable(L, -1)) + if (lua_istable(L, -1) || lua_isnil(L, -1)) return 1; else return lua_error(L); @@ -42,6 +42,8 @@ static void lua_dict_lookup_callback(const struct dict_lookup_result *result, { if (result->ret < 0) { lua_pushstring(L, result->error); + } else if (result->ret == 0) { + lua_pushnil(L); } else { unsigned int i;