Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #561, uninitialised memory access #562

Merged
merged 3 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/luv.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ static void luv_req_init(lua_State* L) {
LUALIB_API int luv_cfpcall(lua_State* L, int nargs, int nresult, int flags) {
int ret, top, errfunc;

top = lua_gettop(L);
// Get the traceback function in case of error
if ((flags & (LUVF_CALLBACK_NOTRACEBACK|LUVF_CALLBACK_NOERRMSG) ) == 0)
{
Expand All @@ -663,7 +664,6 @@ LUALIB_API int luv_cfpcall(lua_State* L, int nargs, int nresult, int flags) {
errfunc -= (nargs+1);
}else
errfunc = 0;
top = lua_gettop(L);

ret = lua_pcall(L, nargs, nresult, errfunc);
switch (ret) {
Expand Down
1 change: 1 addition & 0 deletions src/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static int luv_queue_work(lua_State* L) {
luv_work_t* work = (luv_work_t*)malloc(sizeof(*work));
int ret, n;

memset(work, 0, sizeof(*work));
//prepare lua_State for threadpool
lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->pool_ref);
n = lua_rawlen(L, -1);
Expand Down
9 changes: 9 additions & 0 deletions tests/test-work.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
return require('lib/tap')(function (test)

test("test threadpool with return none", function(print,p,expect,_uv)
local work_fn = function() end
local after_work_fn = function() end
local work_ctx = _uv.new_work(work_fn, after_work_fn)

work_ctx:queue()
end)

test("test threadpool", function(print,p,expect,_uv)
p('Please be patient, the test cost a lots of time')
local count = 1000 --for memleaks dected
Expand Down