mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
Be sure to invoke *lws_free_header_table*:
* Just prior to freeing a session * When allocating a new header table This prevents some memory leaks we've found.
This commit is contained in:
parent
a19d485b80
commit
03f0ceaf97
2 changed files with 4 additions and 0 deletions
|
@ -295,6 +295,8 @@ just_kill_connection:
|
|||
wsi->user_space && !wsi->user_space_externally_allocated)
|
||||
free(wsi->user_space);
|
||||
|
||||
/* As a precaution, free the header table in case it lingered: */
|
||||
lws_free_header_table(wsi);
|
||||
free(wsi);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ int lextable_decode(int pos, char c)
|
|||
|
||||
int lws_allocate_header_table(struct libwebsocket *wsi)
|
||||
{
|
||||
/* Be sure to free any existing header data to avoid mem leak: */
|
||||
lws_free_header_table(wsi);
|
||||
wsi->u.hdr.ah = malloc(sizeof(*wsi->u.hdr.ah));
|
||||
if (wsi->u.hdr.ah == NULL) {
|
||||
lwsl_err("Out of memory\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue