Check json_object_set_new arguments
authorPetri Lehtinen <petri@digip.org>
Sat, 10 Oct 2009 19:53:36 +0000 (22:53 +0300)
committerPetri Lehtinen <petri@digip.org>
Sat, 10 Oct 2009 19:53:36 +0000 (22:53 +0300)
A segfault was caused by NULL key.

src/value.c

index bf5fd54..d8e9e9a 100644 (file)
@@ -148,7 +148,7 @@ int json_object_set_nocheck(json_t *json, const char *key, json_t *value)
 
 int json_object_set_new(json_t *json, const char *key, json_t *value)
 {
-    if(!utf8_check_string(key, -1))
+    if(!key || !utf8_check_string(key, -1))
     {
         json_decref(value);
         return -1;