diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-12-05 18:21:17 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-12-06 02:29:47 +0000 |
commit | 0119cb4fd006b594c491f255c62b58d3e3fffab7 (patch) | |
tree | 7394d6de44c2bbe75d51d7bd38de60d68d583527 /binding/navigation-api.c | |
parent | 2d9012ea413e3bce98f4f616a875a1a21cccbb81 (diff) |
binding: navigation: move get_storage_from_value call within write lockicefish_8.99.2icefish/8.99.28.99.2
json_object returned from get_storage_from_value() needs to be protected
within the write lock. This is to prevent reentrant calls to broadcast() from
accessing it, and running json_object_put()
Bug-AGL: SPEC-2880
Change-Id: I9fdf614728368c75e925e4c5a0f3ca19a7e517e1
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/navigation-api.c')
-rw-r--r-- | binding/navigation-api.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/binding/navigation-api.c b/binding/navigation-api.c index 19913a1..ab7a5b7 100644 --- a/binding/navigation-api.c +++ b/binding/navigation-api.c @@ -135,10 +135,12 @@ static void broadcast(afb_req_t request, const char *name, gboolean cache) json_object *jresp = afb_req_json(request); if (cache) { - json_object **storage = get_storage_from_value(ns, name); + json_object **storage; g_rw_lock_writer_lock(&ns->rw_lock); + storage = get_storage_from_value(ns, name); + if (*storage) json_object_put(*storage); |