aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-ws.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-07-10 00:06:36 +0200
committerJose Bollo <jose.bollo@iot.bzh>2019-07-18 15:38:02 +0200
commit51ab7c2f95d6d459302423a57cc617021ef6126d (patch)
tree20588afd25b3332c0f3c15eee09c8c61c6ff7f29 /src/afb-ws.c
parent6dfeafe7e4fa582b3db3f950136bc97f8611fc6d (diff)
Fix bad memory access at client disconnection
The management of structures handling a client connection to a exported --ws-server was accessing freed memory. Tha commit fixes that issue. Bug-AGL: SPEC-2651 Change-Id: I511218afc907308347bc422a8aead32ca00bdae6 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-ws.c')
-rw-r--r--src/afb-ws.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/afb-ws.c b/src/afb-ws.c
index b2776468..fb31e4fe 100644
--- a/src/afb-ws.c
+++ b/src/afb-ws.c
@@ -120,6 +120,7 @@ static void aws_disconnect(struct afb_ws *ws, int call_on_hangup)
struct websock *wsi = ws->ws;
if (wsi != NULL) {
ws->ws = NULL;
+ fdev_set_callback(ws->fdev, NULL, 0);
fdev_unref(ws->fdev);
websock_destroy(wsi);
free(ws->buffer.buffer);
@@ -133,7 +134,7 @@ static void fdevcb(void *ws, uint32_t revents, struct fdev *fdev)
{
if ((revents & EPOLLIN) != 0)
aws_on_readable(ws);
- if ((revents & EPOLLHUP) != 0)
+ else if ((revents & EPOLLHUP) != 0)
afb_ws_hangup(ws);
}