<p></p>
<p>I have reproduced the issue by calling <code>kz_json_parse(mystr)</code> where <code>mysrt</code> has <code>NULL</code> value.</p>
<div class="highlight highlight-source-diff"><pre><span class="pl-c1">diff --git a/src/modules/kazoo/kz_amqp.c b/src/modules/kazoo/kz_amqp.c</span>
index 8076315dfd..6f5f84716a 100644
<span class="pl-md">--- a/src/modules/kazoo/kz_amqp.c</span>
<span class="pl-mi1">+++ b/src/modules/kazoo/kz_amqp.c</span>
<span class="pl-mdr">@@ -2417,6 +2417,7 @@</span> static void kz_amqp_consumer_event_kemi(void)
 
 void kz_amqp_consumer_event(kz_amqp_consumer_delivery_ptr Evt)
 {
<span class="pl-mi1"><span class="pl-mi1">+</span>       char* mystr = NULL;</span>
        json_obj_ptr json_obj = NULL;
 
        eventData = Evt->payload;
<span class="pl-mdr">@@ -2424,6 +2425,7 @@</span> void kz_amqp_consumer_event(kz_amqp_consumer_delivery_ptr Evt)
                eventKey = Evt->routing_key->s;
        }
 
<span class="pl-mi1"><span class="pl-mi1">+</span>       json_obj = kz_json_parse(mystr);</span>
        json_obj = kz_json_parse(Evt->payload);
        if (json_obj == NULL)
                return;</pre></div>
<p>I have fixed issue by:</p>
<div class="highlight highlight-source-diff"><pre><span class="pl-c1">diff --git a/src/modules/kazoo/kz_json.c b/src/modules/kazoo/kz_json.c</span>
index 5ab8f68c79..0e5f2e8b10 100644
<span class="pl-md">--- a/src/modules/kazoo/kz_json.c</span>
<span class="pl-mi1">+++ b/src/modules/kazoo/kz_json.c</span>
<span class="pl-mdr">@@ -276,6 +276,11 @@</span> struct json_object* kz_json_parse(const char *str)
     struct json_tokener* tok;
     struct json_object* obj;
 
<span class="pl-mi1"><span class="pl-mi1">+</span>    if (str == NULL || str[0] == 0) {</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>      LM_ERR("Error parsing json: empty string\n");</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>      return NULL;</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>    }</span>
<span class="pl-mi1"><span class="pl-mi1">+</span></span>
     tok = json_tokener_new();
     if (!tok) {
       LM_ERR("Error parsing json: could not allocate tokener\n");</pre></div>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2794#issuecomment-872595128">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZPWJL46ZQCVIOVIES3TVTWFFANCNFSM47VQSK7Q">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZO6CE3ZKIJA5TOHPFDTVTWFFA5CNFSM47VQSK72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGQBL5OA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2794#issuecomment-872595128",
"url": "https://github.com/kamailio/kamailio/issues/2794#issuecomment-872595128",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>