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 void clock_cb(const pj_timestamp *ts, void *user_data)
{
    dtls_srtp_channel *ds_ch = (dtls_srtp_channel*)user_data;
    dtls_srtp *ds = ds_ch->dtls_srtp;
    unsigned idx = ds_ch->channel;

    PJ_UNUSED_ARG(ts);

    pj_lock_acquire(ds->ossl_lock);

    if (!ds->ossl_ssl[idx]) {
        pj_lock_release(ds->ossl_lock);
        return;
    }

    if (DTLSv1_handle_timeout(ds->ossl_ssl[idx]) > 0) {
        pj_lock_release(ds->ossl_lock);
        ssl_flush_wbio(ds, idx);
    } else {
        pj_lock_release(ds->ossl_lock);
    }
}