Browse Source

Handle NULL objects in json_object_get_userdata() by returning NULL, but abort in json_object_set_userdata() since we can't actually do anything with the userdata.

tags/json-c-0.13-20171207
Eric Haszlakiewicz 9 years ago
parent
commit
d4899bd4d5
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      json_object.c

+ 4
- 1
json_object.c View File

@@ -241,12 +241,15 @@ enum json_type json_object_get_type(const struct json_object *jso)
}

void* json_object_get_userdata(json_object *jso) {
return jso->_userdata;
return jso ? jso->_userdata : NULL;
}

void json_object_set_userdata(json_object *jso, void *userdata,
json_object_delete_fn *user_delete)
{
// Can't return failure, so abort if we can't perform the operation.
assert(jso != NULL);

// First, clean up any previously existing user info
if (jso->_user_delete)
jso->_user_delete(jso, jso->_userdata);


Loading…
Cancel
Save