From e273e0ef19f374baf35111584b65e619e3dbcaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 3 Sep 2012 17:52:45 +0200 Subject: Handle JSON value "null" instead of crashing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Future json-c versions will handle this transparently, for now we have to do it manually. Signed-off-by: Miloslav Trmač --- plugins/ommongodb/ommongodb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugins/ommongodb/ommongodb.c') diff --git a/plugins/ommongodb/ommongodb.c b/plugins/ommongodb/ommongodb.c index c1648c50..2c65f275 100644 --- a/plugins/ommongodb/ommongodb.c +++ b/plugins/ommongodb/ommongodb.c @@ -296,7 +296,9 @@ static bson *BSONFromJSONObject(struct json_object *json); static gboolean BSONAppendJSONObject(bson *doc, const gchar *name, struct json_object *json) { - switch(json_object_get_type(json)) { + switch(json != NULL ? json_object_get_type(json) : json_type_null) { + case json_type_null: + return bson_append_null(doc, name); case json_type_boolean: return bson_append_boolean(doc, name, json_object_get_boolean(json)); -- cgit v1.2.3