From 2a4a8e765c9cb7825e20f6490ea483d3d8968925 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sat, 26 Jan 2008 01:41:02 +0000 Subject: [PATCH] try to not segfault git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7364 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c | 4 +++- libs/sofia-sip/libsofia-sip-ua/su/su_root.c | 22 ++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c b/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c index ad735077fd..d150f563e3 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c @@ -780,7 +780,8 @@ void *su_alloc(su_home_t *home, isize_t size) */ void su_free(su_home_t *home, void *data) { - if (home && data) { + if (data) { + if (home) { su_alloc_t *allocation; su_block_t *sub = MEMLOCK(home); @@ -825,6 +826,7 @@ void su_free(su_home_t *home, void *data) } free(data); + } } /** Check home consistency. diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_root.c b/libs/sofia-sip/libsofia-sip-ua/su/su_root.c index 9b0db85420..42fd813428 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_root.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_root.c @@ -1046,19 +1046,19 @@ void su_msg_save(su_msg_r save, su_msg_r rmsg) */ void su_msg_destroy(su_msg_r rmsg) { + su_msg_t *msg = rmsg[0]; 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); - - if (rmsg[0]->sum_deinit) - rmsg[0]->sum_deinit(rmsg[0]->sum_data); - - su_free(NULL, rmsg[0]); - } - rmsg[0] = NULL; + + if (msg) { + SU_TASK_ZAP(msg->sum_to, su_msg_destroy); + SU_TASK_ZAP(msg->sum_from, su_msg_destroy); + + if (msg->sum_deinit) + msg->sum_deinit(msg->sum_data); + + su_free(NULL, msg); + } } /** Gets a pointer to the message data area.