aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-02-08 13:09:39 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2019-02-08 18:29:31 +0100
commitd9c73d75c7a8ab46dce9b716f695beea90e88a5d (patch)
treebd0c4d92a8142d802fbf5ec95b327ab31d39dff5
parent74f381d988cd04707c2044ca2a201ad8bf87a6f3 (diff)
afb-stub-ws: Fix concurrent memory issuesflounder_6.0.5flounder/6.0.56.0.5
This changes takes care to increment the the count of reference before using it. Bug-AGL: SPEC-2163 Change-Id: Ia7882427eeae933eeb5030aad025ebb1da129d6f Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-stub-ws.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c
index 9bc52044..c334fe15 100644
--- a/src/afb-stub-ws.c
+++ b/src/afb-stub-ws.c
@@ -265,6 +265,7 @@ static void client_api_call_cb(void * closure, struct afb_xreq *xreq)
return;
}
+ afb_xreq_unhooked_addref(xreq);
rc = afb_proto_ws_client_call(
proto,
xreq->request.called_verb,
@@ -272,10 +273,10 @@ static void client_api_call_cb(void * closure, struct afb_xreq *xreq)
afb_session_uuid(xreq->context.session),
xreq,
xreq_on_behalf_cred_export(xreq));
- if (rc >= 0)
- afb_xreq_unhooked_addref(xreq);
- else
+ if (rc < 0) {
afb_xreq_reply(xreq, NULL, "internal", "can't send message");
+ afb_xreq_unhooked_unref(xreq);
+ }
}
static void client_on_description_cb(void *closure, struct json_object *data)