Commit efc9a6b0 authored by Javier Peletier's avatar Javier Peletier Committed by Arnim Läuger
Browse files

fix memory leak in http one-shot requests (#2615)

parent ca92cfd3
......@@ -648,10 +648,9 @@ static int http_accumulate_complete(lua_State *L)
lua_rawseti(L, cache_table, i);
}
luaL_pushresult(&b); // data now pushed
lhttp_context_t *context = (lhttp_context_t *)luaL_checkudata(L, context_idx, http_context_mt);
if (lua_isnoneornil(L, 1)) {
// No callback fn so must be sync, meaning just need to stash headers and data in the context
lhttp_context_t *context = (lhttp_context_t *)luaL_checkudata(L, context_idx, http_context_mt);
// steal some completion refs, nothing's going to need them again in a one-shot
context_setref(L, context, DataCallback); // pops data
lua_rawgeti(L, cache_table, 2); // headers
......@@ -660,6 +659,8 @@ static int http_accumulate_complete(lua_State *L)
lua_rawgeti(L, cache_table, 2); // headers
lua_call(L, 3, 0);
}
// unset this since it contains a reference to the context and would prevent the context to be garbage collected
context_unsetref(L, context,CompleteCallback);
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment