Language: C
Label: safe
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);

    DTLS_LOCK(ds);

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

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