lua: fix memory leak in set method
authorPetr Štetiar <ynezz@true.cz>
Mon, 4 Nov 2019 22:08:26 +0000 (23:08 +0100)
committerPetr Štetiar <ynezz@true.cz>
Thu, 14 Nov 2019 16:11:34 +0000 (17:11 +0100)
commit39093f3b040df895da812e2932b55feeeb1201df
tree1a4e1442eddc8a22a770cd9b96d9f127b1b98aea
parent19ceff323f1e2e7df26031a9fae29fff2edc65bd
lua: fix memory leak in set method

scan-build from clang version 9 has reported following issue:

 uci.c:624:12: warning: Potential leak of memory pointed to by 's'
       return luaL_error(L, "Cannot set an uci option to an empty table value");
              ^~~~~~~~~~

valgrind confirmed it on the supplied test case:

 ==31013== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
 ==31013==    by 0x56C49B9: strdup (strdup.c:42)

Signed-off-by: Petr Štetiar <ynezz@true.cz>
lua/uci.c
tests/cram/lua/test_cases/set_with_empty_table_doesnt_leak.lua [new file with mode: 0644]
tests/cram/test_ucilua_testcases.t