aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-02-08 13:09:39 +0100
committerLoïc Collignon <loic.collignon@iot.bzh>2019-02-27 17:54:25 +0100
commit786c7319f59895824e4049ca6915ecfc045f5eee (patch)
tree97e82525c18b30e1cea116781815b609a6eb4c0a
parent16dcd58f2beb3f7e65a70cbc8e05aef74c8e437e (diff)
afb-stub-ws: Fix concurrent memory issues
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 70c74b65..02070f46 100644
--- a/src/afb-stub-ws.c
+++ b/src/afb-stub-ws.c
@@ -266,6 +266,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,
@@ -273,10 +274,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)