diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-09-21 00:17:56 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-09-21 00:17:56 +0000 |
commit | 120abb5ecd72fefa6aadccabf51ee4af984ee522 (patch) | |
tree | 573778a3556fe9d06d35b5d8109d831e422bc0e9 /main/json.c | |
parent | 6cc3084ae7bc927587865c1e3331fcc5031df9e7 (diff) |
json: Make it obvious that ast_json_unref() is NULL safe.
It looked like the safety check was done after the NULL pointer was used.
........
Merged revisions 399576 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399578 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/json.c')
-rw-r--r-- | main/json.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/main/json.c b/main/json.c index 8658502b3..5e50c424a 100644 --- a/main/json.c +++ b/main/json.c @@ -213,13 +213,15 @@ void ast_json_unref(struct ast_json *json) struct json_mem_list *free_list; struct json_mem *mem; + if (!json) { + return; + } + /* Jansson refcounting is non-atomic; lock it. */ { SCOPED_JSON_LOCK(json); - if (!json) { - return; - } - json_decref((json_t *)json); + + json_decref((json_t *) json); } /* Now free any objects that were ast_json_free()'s while the lock was |