Pseudocode da una client library open source:
static int send_command_final(struct iax_session *i, ...) {
    r = schedule_transmit_at_a_later_time(i, ...);
    if (r >=0) {
        free(i);
    }
}

Se sei sicuro, lascia che ti assicuri che non c'è nessuna magia in schedule_transmit_at_a_later_time function: niente cloning, niente reference counting, nulla del genere. Questo codice spera solo che la struttura sarà valida dopo la free. Basta aggiungere una memset prima della free per vedere esplodere tutto. WTF?

Pseudocode from an open source client library:

static int send_command_final(struct iax_session *i, ...) {
    r = schedule_transmit_at_a_later_time(i, ...);
    if (r >=0) {
        free(i);
    }
}
In case you're confused, let me assure you, there is no magic going on in the schedule_transmit_at_a_later_time function: no cloning, no reference counting, nothing like that. This code just hopes the freed structure will still be valid if/when the transmission does occur. Just add a memset before the free and see it explode in technicolor. WTF?