]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
try to not segfault
authorMichael Jerris <mike@jerris.com>
Sat, 26 Jan 2008 01:41:02 +0000 (01:41 +0000)
committerMichael Jerris <mike@jerris.com>
Sat, 26 Jan 2008 01:41:02 +0000 (01:41 +0000)
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
libs/sofia-sip/libsofia-sip-ua/su/su_root.c

index ad735077fd06e94bdeb98cda06865983de82b754..d150f563e3689badb6c9069cdbfb333382139194 100644 (file)
@@ -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.
index 9b0db85420d222d5159c58b81570cdd89dd896e6..42fd813428bcad4a8f20341f9e79cb3a6df5247b 100644 (file)
@@ -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);
+  rmsg[0] = NULL;
 
-  if (rmsg[0]) {
-    SU_TASK_ZAP(rmsg[0]->sum_to, su_msg_destroy);
-    SU_TASK_ZAP(rmsg[0]->sum_from, su_msg_destroy);
+  if (msg) {
+    SU_TASK_ZAP(msg->sum_to, su_msg_destroy);
+    SU_TASK_ZAP(msg->sum_from, su_msg_destroy);
 
-    if (rmsg[0]->sum_deinit)
-      rmsg[0]->sum_deinit(rmsg[0]->sum_data);
+    if (msg->sum_deinit)
+      msg->sum_deinit(msg->sum_data);
 
-    su_free(NULL, rmsg[0]);
+    su_free(NULL, msg);
   }
-
-  rmsg[0] = NULL;
 }
 
 /** Gets a pointer to the message data area.