Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
efc9a6b0
Commit
efc9a6b0
authored
Jan 16, 2019
by
Javier Peletier
Committed by
Arnim Läuger
Jan 16, 2019
Browse files
fix memory leak in http one-shot requests (#2615)
parent
ca92cfd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
components/modules/http.c
View file @
efc9a6b0
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment