diff options
author | Andy Green <andy@warmcat.com> | 2020-03-19 17:03:11 +0000 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2020-03-19 17:03:11 +0000 |
commit | 77a1b4e058520aa2eed2dfc2f2dfac560e9309c5 (patch) | |
tree | ff4d7052994821abfa25954531c75775d9983d36 | |
parent | 8aef4cc330a508b3447e5862fbdf4c2cc8cfe3c1 (diff) | |
download | libwebsockets-77a1b4e058520aa2eed2dfc2f2dfac560e9309c5.tar.gz |
lws_set_wsi_user: allow setting to override existing internal allocation
-rw-r--r-- | lib/core-net/wsi.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/core-net/wsi.c b/lib/core-net/wsi.c index 78e086e5..46566100 100644 --- a/lib/core-net/wsi.c +++ b/lib/core-net/wsi.c @@ -637,14 +637,11 @@ lws_wsi_user(struct lws *wsi) void lws_set_wsi_user(struct lws *wsi, void *data) { - /* client and user owns it... */ - if (wsi->user_space_externally_allocated || - /* server, and protocol can never own it, user can control it... */ - (wsi->protocol && !wsi->protocol->per_session_data_size)) - wsi->user_space = data; - else - lwsl_err("%s: Cannot set internally-allocated user_space\n", - __func__); + if (!wsi->user_space_externally_allocated && wsi->user_space) + lws_free(wsi->user_space); + + wsi->user_space_externally_allocated = 1; + wsi->user_space = data; } struct lws * |