dont free externally allocated user_space when closing connection
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
d6827f7741
commit
97850857b3
3 changed files with 5 additions and 2 deletions
|
@ -434,8 +434,10 @@ libwebsocket_client_connect_extended(struct libwebsocket_context *context,
|
|||
ssl_connection, path, host, origin, protocol,
|
||||
ietf_version_or_minus_one);
|
||||
|
||||
if (ws && !ws->user_space && userdata)
|
||||
if (ws && !ws->user_space && userdata) {
|
||||
ws->user_space_externally_allocated = 1;
|
||||
ws->user_space = userdata ;
|
||||
}
|
||||
|
||||
return ws ;
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ just_kill_connection:
|
|||
LWS_CALLBACK_WSI_DESTROY, wsi->user_space, NULL, 0);
|
||||
|
||||
if (wsi->protocol && wsi->protocol->per_session_data_size &&
|
||||
wsi->user_space) /* user code may own */
|
||||
wsi->user_space && !wsi->user_space_externally_allocated)
|
||||
free(wsi->user_space);
|
||||
|
||||
free(wsi);
|
||||
|
|
|
@ -581,6 +581,7 @@ struct libwebsocket {
|
|||
char rx_frame_type; /* enum libwebsocket_write_protocol */
|
||||
|
||||
unsigned int hdr_parsing_completed:1;
|
||||
unsigned int user_space_externally_allocated:1;
|
||||
|
||||
char pending_timeout; /* enum pending_timeout */
|
||||
time_t pending_timeout_limit;
|
||||
|
|
Loading…
Add table
Reference in a new issue