diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-27 11:49:47 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-27 11:49:47 +0100 |
commit | 2a8231db5d2bb2590f419df73c5a529d39ff1a22 (patch) | |
tree | 9f33ad0265335cd56cc78917c91a6c408a631f4e /src/lua/lua_regexp.c | |
parent | 24a0be9cf3f7aa22160a43e06fa94924b7e7065a (diff) | |
download | rspamd-2a8231db5d2bb2590f419df73c5a529d39ff1a22.tar.gz rspamd-2a8231db5d2bb2590f419df73c5a529d39ff1a22.zip |
[Minor] Fix return values in Lua API
Diffstat (limited to 'src/lua/lua_regexp.c')
-rw-r--r-- | src/lua/lua_regexp.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c index a677f7195..7277f192f 100644 --- a/src/lua/lua_regexp.c +++ b/src/lua/lua_regexp.c @@ -588,12 +588,14 @@ lua_regexp_search (lua_State *L) if (capture) { g_array_free (captures, TRUE); } - - return 1; + } + else { + lua_pushnil (L); } } - - lua_pushnil (L); + else { + return luaL_error (L, "invalid arguments"); + } return 1; } @@ -644,11 +646,14 @@ lua_regexp_match (lua_State *L) else { lua_pushboolean (L, FALSE); } - return 1; + } + else { + lua_pushboolean (L, FALSE); } } - - lua_pushnil (L); + else { + return luaL_error (L, "invalid arguments"); + } return 1; } @@ -689,13 +694,13 @@ lua_regexp_matchn (lua_State *L) } max_matches = lua_tointeger (L, 3); + matches = 0; if (lua_gettop (L) == 4) { raw = lua_toboolean (L, 4); } if (data && len > 0) { - matches = 0; if (re->match_limit > 0) { len = MIN (len, re->match_limit); @@ -714,14 +719,14 @@ lua_regexp_matchn (lua_State *L) break; } } - - lua_pushinteger (L, matches); - - return 1; } + + lua_pushinteger (L, matches); + } + else { + return luaL_error (L, "invalid arguments"); } - lua_pushnil (L); return 1; } @@ -825,6 +830,9 @@ lua_regexp_split (lua_State *L) return 1; } } + else { + return luaL_error (L, "invalid arguments"); + } lua_pushnil (L); return 1; |