]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: frrscript_call check name before decode
authorDonald Lee <dlqs@gmx.com>
Wed, 7 Jul 2021 13:53:10 +0000 (21:53 +0800)
committerDonald Lee <dlqs@gmx.com>
Sat, 17 Jul 2021 22:32:03 +0000 (06:32 +0800)
Signed-off-by: Donald Lee <dlqs@gmx.com>
lib/frrscript.h

index 0d5568d3421dd42e114b35159e4608fbb27266ab..1e35e2ee4108e9d1c0f2b60402d7945e367b43d0 100644 (file)
@@ -123,7 +123,12 @@ void frrscript_init(const char *scriptdir);
 #define DECODE_ARGS(name, value)                                               \
        do {                                                                   \
                lua_getfield(lfs->L, 1, name);                                 \
-               DECODE_ARGS_WITH_STATE(lfs->L, value);                         \
+               if (lua_isnil(lfs->L, 2)) {                                    \
+                       lua_pop(lfs->L, 1);                                    \
+               } else {                                                       \
+                       DECODE_ARGS_WITH_STATE(lfs->L, value);                 \
+               }                                                              \
+               assert(lua_gettop(lfs->L) == 1);                               \
        } while (0)
 
 /*