]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Fix json_object_object_get() so it returns NULL if the incoming json_object is NULL.
authorEric Haszlakiewicz <erh+git@nimenees.com>
Thu, 18 Oct 2012 22:14:41 +0000 (17:14 -0500)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Thu, 18 Oct 2012 22:14:41 +0000 (17:14 -0500)
json_object.c

index bb344af0965ee320c0ac04530ccefb96d81b1eb9..4c179ab06b26bb90caee9a8bdec3400addc037fc 100644 (file)
@@ -390,13 +390,16 @@ void json_object_object_add(struct json_object* jso, const char *key,
 
 struct json_object* json_object_object_get(struct json_object* jso, const char *key)
 {
-  struct json_object *result;
+  struct json_object *result = NULL;
   json_object_object_get_ex(jso, key, &result);
   return result;
 }
 
 json_bool json_object_object_get_ex(struct json_object* jso, const char *key, struct json_object **value)
 {
+       if (value != NULL)
+               *value = NULL;
+
   if (NULL == jso) return FALSE;
 
   switch(jso->o_type) {