mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
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
This commit is contained in:
10
main/json.c
10
main/json.c
@@ -213,13 +213,15 @@ void ast_json_unref(struct ast_json *json)
|
|||||||
struct json_mem_list *free_list;
|
struct json_mem_list *free_list;
|
||||||
struct json_mem *mem;
|
struct json_mem *mem;
|
||||||
|
|
||||||
|
if (!json) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Jansson refcounting is non-atomic; lock it. */
|
/* Jansson refcounting is non-atomic; lock it. */
|
||||||
{
|
{
|
||||||
SCOPED_JSON_LOCK(json);
|
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
|
/* Now free any objects that were ast_json_free()'s while the lock was
|
||||||
|
Reference in New Issue
Block a user