Commit 391045e6 authored by Pekka Pessi's avatar Pekka Pessi

su_root.c: try not to segfault in su_msg_destroy()

Reduced window for race condition in su_msg_destroy().

Patch by Michael Jerris.

darcs-hash:20080128143048-65a35-482eae24e8a9d25faa045297bbcf28ebd794092d.gz
parent 3399be61
......@@ -1046,19 +1046,21 @@ void su_msg_save(su_msg_r save, su_msg_r rmsg)
*/
void su_msg_destroy(su_msg_r rmsg)
{
su_msg_t *msg;
assert(rmsg);
if (rmsg[0]) {
SU_TASK_ZAP(rmsg[0]->sum_to, su_msg_destroy);
SU_TASK_ZAP(rmsg[0]->sum_from, su_msg_destroy);
msg = rmsg[0], rmsg[0] = NULL;
if (rmsg[0]->sum_deinit)
rmsg[0]->sum_deinit(rmsg[0]->sum_data);
if (msg) {
SU_TASK_ZAP(msg->sum_to, su_msg_destroy);
SU_TASK_ZAP(msg->sum_from, su_msg_destroy);
su_free(NULL, rmsg[0]);
}
if (msg->sum_deinit)
msg->sum_deinit(msg->sum_data);
rmsg[0] = NULL;
su_free(NULL, msg);
}
}
/** Gets a pointer to the message data area.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment