From f8f82901cdd0ccd5308e05c73af6deb7d083720f Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 1 Feb 2023 12:54:22 +0100 Subject: fix(tests): fixes for using vim.mpack and more ASAN --- src/mpack/lmpack.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/mpack/lmpack.c') diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 53d7092a0c..957bac37cc 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -644,7 +644,13 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node) mpack_node_t *n; int has_meta = lua_getmetatable(L, -1); - if (packer->ext != LUA_NOREF && has_meta) { + int has_mtdict = false; + if (has_meta && packer->mtdict != LUA_NOREF) { + lmpack_geti(L, packer->reg, packer->mtdict); // [table, metatable, mtdict] + has_mtdict = lua_rawequal(L, -1, -2); + lua_pop(L, 1); // [table, metatable]; + } + if (packer->ext != LUA_NOREF && has_meta && !has_mtdict) { /* check if there's a handler for this metatable */ lmpack_geti(L, packer->reg, packer->ext); lua_pushvalue(L, -2); @@ -701,14 +707,7 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node) } } - int is_array = 1; if (has_meta) { - // stack: [table, metatable] - if (packer->mtdict != LUA_NOREF) { - lmpack_geti(L, packer->reg, packer->mtdict); // [table, metatable, mtdict] - is_array = !lua_rawequal(L, -1, -2); - lua_pop(L, 1); // [table, metatable]; - } lua_pop(L, 1); // [table] } @@ -726,6 +725,7 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node) lua_pop(L, 1); } + int is_array = !has_mtdict; len = lmpack_objlen(L, &is_array); if (is_array) { node->tok = mpack_pack_array(len); -- cgit From 1e60e8c0406f6b4b51c51abb5f53e25bd52fee5e Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 15 Apr 2023 12:23:45 +0200 Subject: refactor(build): use vendored versions of mpack and luabitop --- src/mpack/lmpack.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mpack/lmpack.c') diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 957bac37cc..8b45136cae 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -1171,6 +1171,9 @@ static const luaL_reg mpack_functions[] = { {NULL, NULL} }; +#ifdef NLUA_WIN32 + __declspec(dllexport) +#endif int luaopen_mpack(lua_State *L) { /* Unpacker */ -- cgit From ffaf74f1477d3182ffc70bcc9913effc44c90ea7 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 20 Apr 2023 14:41:47 +0200 Subject: fix(build): distinguish vim.mpack from global require'mpack' problem: the api of vim.mpack is not compatible with a system provided mpack solution: don't require 'mpack' directly from the system path --- src/mpack/lmpack.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/mpack/lmpack.c') diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 8b45136cae..957bac37cc 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -1171,9 +1171,6 @@ static const luaL_reg mpack_functions[] = { {NULL, NULL} }; -#ifdef NLUA_WIN32 - __declspec(dllexport) -#endif int luaopen_mpack(lua_State *L) { /* Unpacker */ -- cgit From 307a7abf86c439177910d05003a81ea4a13d2650 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 9 Oct 2023 11:29:21 +0200 Subject: build(deps): bump libmpack-lua to 1.0.11 update vendored libmpack-lua to match https://github.com/libmpack/libmpack-lua/releases/tag/1.0.11 --- src/mpack/lmpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mpack/lmpack.c') diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 957bac37cc..3c7108a337 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -233,7 +233,7 @@ static mpack_uint32_t lmpack_objlen(lua_State *L, int *is_array) while (lua_next(L, -2)) { lua_pop(L, 1); /* pop value */ isarr = isarr - && lua_isnumber(L, -1) /* lua number */ + && lua_type(L, -1) == LUA_TNUMBER /* lua number */ && (n = lua_tonumber(L, -1)) > 0 /* greater than 0 */ && (size_t)n == n; /* and integer */ max = isarr && (size_t)n > max ? (size_t)n : max; -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/mpack/lmpack.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/mpack/lmpack.c') diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 3c7108a337..6e693bcc5d 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /* * This module exports three classes, and each instance of those classes has its * own private registry for temporary reference storage(keeping state between @@ -246,7 +243,7 @@ static mpack_uint32_t lmpack_objlen(lua_State *L, int *is_array) } end: - if ((size_t)-1 > (mpack_uint32_t)-1 && len > (mpack_uint32_t)-1) // -V560 + if ((size_t)-1 > (mpack_uint32_t)-1 && len > (mpack_uint32_t)-1) /* msgpack spec doesn't allow lengths > 32 bits */ len = (mpack_uint32_t)-1; assert(top == lua_gettop(L)); -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/mpack/lmpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mpack/lmpack.c') diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c index 6e693bcc5d..ff21e29789 100644 --- a/src/mpack/lmpack.c +++ b/src/mpack/lmpack.c @@ -24,7 +24,7 @@ #include #include -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "lmpack.h" -- cgit