]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/lua: change arg name to reflect correctness
authorShivani Bhardwaj <shivani@oisf.net>
Wed, 26 Mar 2025 06:04:11 +0000 (11:34 +0530)
committerVictor Julien <victor@inliniac.net>
Tue, 1 Apr 2025 08:17:07 +0000 (10:17 +0200)
lua fns do not care about the argument count, they work with the index of
the item in the stack. Before library, there was just one item on the stack
so it worked out, however, with the library, the first item in the stack is
the library userdata, so, the fn would fail with the existing hard coded
setting of 1 for argc which can easily be confused with the number of
arguments passed to the fn.

src/util-lua-common.c

index cfd349bc8e6c1ce17e46983cd1243d962719793d..f24863f172d17ef116eb40a092a93a9fa2a37de0 100644 (file)
@@ -63,12 +63,12 @@ int LuaCallbackError(lua_State *luastate, const char *msg)
     return 2;
 }
 
-const char *LuaGetStringArgument(lua_State *luastate, int argc)
+const char *LuaGetStringArgument(lua_State *luastate, int idx)
 {
     /* get argument */
-    if (!lua_isstring(luastate, argc))
+    if (!lua_isstring(luastate, idx))
         return NULL;
-    const char *str = lua_tostring(luastate, argc);
+    const char *str = lua_tostring(luastate, idx);
     if (str == NULL)
         return NULL;
     if (strlen(str) == 0)