Browse code

kazoo: fixed crash when json body is NULL

fixes GH #2794

(cherry picked from commit d8955fc350b48d0c4ca359d03cb9954a48998658)

Sergey Safarov authored on 15/09/2021 13:14:13 • Daniel-Constantin Mierla committed on 16/09/2021 11:12:57
Showing 1 changed files
... ...
@@ -276,6 +276,11 @@ struct json_object* kz_json_parse(const char *str)
276 276
     struct json_tokener* tok;
277 277
     struct json_object* obj;
278 278
 
279
+    if (str == NULL || str[0] == 0) {
280
+      LM_ERR("Error parsing json: empty string\n");
281
+      return NULL;
282
+    }
283
+
279 284
     tok = json_tokener_new();
280 285
     if (!tok) {
281 286
       LM_ERR("Error parsing json: could not allocate tokener\n");