<p>If <code>avp_db_query</code> is used in the script but <code>db_url</code> was not set as a modparam for avpops then OpenSIPS will segfault on startup.</p>

<pre><code>* thread #1: tid = 0x0000, 0x0000000104325a8f avpops.so`avpops_db_bind + 159 at avpops_db.c:157, stop reason = signal SIGSTOP
  * frame #0: 0x0000000104325a8f avpops.so`avpops_db_bind + 159 at avpops_db.c:157
    frame #1: 0x0000000104320a54 avpops.so`avpops_init + 292 at avpops.c:240
    frame #2: 0x0000000103851240 opensips`init_mod(m=0x0000000103a1ddd0, skip_others=&lt;unavailable&gt;) + 320 at sr_module.c:632
    frame #3: 0x00000001038510e4 opensips`init_modules + 20 at sr_module.c:676
    frame #4: 0x00000001037ffdf6 opensips`main(argc=&lt;unavailable&gt;, argv=&lt;unavailable&gt;) + 9334 at main.c:1205
    frame #5: 0x00007fff8370c5c9 libdyld.dylib`start + 1
</code></pre>

<p>Looks to be a result of <code>get_default_db_url</code> returning NULL and then <code>avops_db_bind</code> trying to use <code>default_db_url</code> without checking for the possibility of it being NULL.</p>

<p>Seems like another check in <code>avops_db_bind</code> for <code>default_db_url</code> being NULL in the case that a DB function is used would solve the problem.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/issues/644">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOciY3bUzXQVqcY1wmSH2mX8FDTe2Gaks5o0CGjgaJpZM4GA_2O.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/OpenSIPS/opensips/issues/644"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>