rem: T->outbound_request[branch]->buffer   = (char*)sh_malloc( len );
add: if ( !(T->outbound_request[branch]->buffer   = (char*)sh_malloc( len ))) { LOG(L_ERR, "ERROR: t_forward: shmem allocation failed\n"); free( buf ); return -1; }
context: int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int dest_port_param ){   int	branch = 0;	/* we don't do any forking right now */   /* it's about the same transaction or not? */   if ( global_msg_id != p_msg->id )   {      T = (struct cell*)-1;      global_msg_id = p_msg->id;   }   DBG("t_forward: 1. T=%x\n", T);   /* if  T hasn't been previous searched -> search for it */   if ( (int)T ==-1 )      t_lookup_request( p_msg, 0 , 0 );   DBG("t_forward: 2. T=%x\n", T);   /*if T hasn't been found after all -> return not found (error) */   if ( !T )      return -1;   /*if it's an ACK and the status is not final or is final, but error the ACK is not forwarded*/   if ( p_msg->first_line.u.request.method_value==METHOD_ACK  && (T->status/100)!=2 ) {      DBG("DEBUG: t_forward: local ACK; don't forward\n");      return 1;   }   /* if it's forwarded for the first time ; else the request is retransmited from the transaction buffer */   if ( T->outbound_request[branch]==NULL )   {      unsigned int dest_ip     = dest_ip_param;      unsigned int dest_port  = dest_port_param;      unsigned int len;      char               *buf;      DBG("DEBUG: t_forward: first time forwarding\n");      /* allocates a new retrans_buff for the outbound request */      T->outbound_request[branch] = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );      memset( T->outbound_request[branch] , 0 , sizeof (struct retrans_buff) );      T->nr_of_outgoings = 1;      /* special case : CANCEL */      if ( p_msg->first_line.u.request.method_value==METHOD_CANCEL  )      {         struct cell  *T2;         DBG("DEBUG: t_forward: it's CANCEL\n");         /* find original cancelled transaction; if found, use its next-hops; otherwise use those passed by script */         T2 = t_lookupOriginalT( hash_table , p_msg );         /* if found */         if (T2)         {  /* if in 1xx status, send to the same destination */            if ( (T2->status/100)==1 )            {               DBG("DEBUG: t_forward: it's CANCEL and I will send to the same place where INVITE went\n");               dest_ip    = T2->outbound_request[branch]->dest_ip;               dest_port = T2->outbound_request[branch]->dest_port;            }            else            {               /* transaction exists, but nothing to cancel */               DBG("DEBUG: t_forward: it's CANCEL but I have nothing to cancel here\n");               return 1;            }         }      }/* end special case CANCEL*/      /* store */      DBG("DEBUG: t_forward: building outbound request\n");      T->outbound_request[branch]->tl[RETRASMISSIONS_LIST].payload = &(T->outbound_request[branch]);      T->outbound_request[branch]->dest_ip         = dest_ip;      T->outbound_request[branch]->dest_port      = dest_port;      T->outbound_request[branch]->to.sin_family = AF_INET;      T->outbound_request[branch]->to.sin_port     =  dest_port;      T->outbound_request[branch]->to.sin_addr.s_addr =  dest_ip;      if (add_branch_label( T, p_msg , branch )==-1) return -1;      buf = build_req_buf_from_sip_req  ( p_msg, &len);      if (!buf)         return -1;      T->outbound_request[branch]->bufflen = len ;      T->outbound_request[branch]->buffer   = (char*)sh_malloc( len );      memcpy( T->outbound_request[branch]->buffer , buf , len );      free( buf ) ;      DBG("DEBUG: t_forward: starting timers (retrans and FR)\n");      /*sets and starts the FINAL RESPONSE timer */      add_to_tail_of_timer_list( hash_table , &(T->outbound_request[branch]->tl[FR_TIMER_LIST]) , FR_TIMER_LIST, FR_TIME_OUT );      /* sets and starts the RETRANS timer */      T->outbound_request[branch]->timeout_ceiling  = RETR_T2;      T->outbound_request[branch]->timeout_value    = RETR_T1;      insert_into_timer_list( hash_table , &(T->outbound_request[branch]->tl[RETRASMISSIONS_LIST]), RETRASMISSIONS_LIST , RETR_T1 );   }/* end for the first time */   DBG("DEBUG: t_forward: sending outbund request from buffer\n");   /* send the request */   udp_send( T->outbound_request[branch]->buffer , T->outbound_request[branch]->bufflen ,                    (struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );   return 1;}