Language: C
Label: vulnerable
CWE: CWE-416 \u2014 Use After Free
Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.

Code:
static pj_status_t dtls_destroy(pjmedia_transport *tp)
{
    dtls_srtp *ds = (dtls_srtp *)tp;

#if DTLS_DEBUG
    PJ_LOG(2,(ds->base.name, "dtls_destroy()"));
#endif

    dtls_destroy_channel(ds, RTP_CHANNEL);
    dtls_destroy_channel(ds, RTCP_CHANNEL);

    if (ds->ossl_lock) {
        pj_lock_destroy(ds->ossl_lock);
        ds->ossl_lock = NULL;
    }

    pj_pool_safe_release(&ds->pool);

    return PJ_SUCCESS;
}