rem: free(new_buf); error1:
add: if (new_buf) free(new_buf); if (to) free(to);
context: int forward_request(char * orig, char* buf, 					 unsigned int len,					 struct sip_msg* msg,					 struct route_elem* re,					 unsigned long source_ip){	unsigned int new_len, via_len, received_len;	char line_buf[MAX_VIA_LINE_SIZE];	char received_buf[MAX_RECEIVED_SIZE];	char* new_buf;	int offset, s_offset, size;	struct sockaddr_in to;	received_len=0;	via_len=snprintf(line_buf, MAX_VIA_LINE_SIZE, "Via: SIP/2.0/UDP %s:%d\r\n",						names[0], port_no);	/* check if received needs to be added */	if (check_address(source_ip, msg->via1.host, received_dns)!=0){		received_len=snprintf(received_buf, MAX_RECEIVED_SIZE,								";received=%s", 								inet_ntoa(*(struct in_addr *)&source_ip));	}		new_len=len+via_len+received_len;	new_buf=(char*)malloc(new_len+1);	if (new_buf==0){		DPrint("ERROR: forward_request: out of memory\n");		goto error1;	}/* copy msg till first via */	offset=s_offset=0;	size=msg->via1.hdr-buf;	memcpy(new_buf, orig, size);	offset+=size;	s_offset+=size; /* add our via */	memcpy(new_buf+offset, line_buf, via_len);	offset+=via_len; /* modify original via if neccesarry (received=...)*/	if (received_len){		if (msg->via1.params){				size= msg->via1.params-msg->via1.hdr-1; /*compensate for ';' */		}else{				size= msg->via1.host-msg->via1.hdr+strlen(msg->via1.host);				if (msg->via1.port!=0){					size+=strlen(msg->via1.hdr+size+1)+1; /* +1 for ':'*/				}		}		memcpy(new_buf+offset, orig+s_offset, 								size);		offset+=size;		s_offset+=size;		memcpy(new_buf+offset, received_buf, received_len);		offset+=received_len;	} 	/* copy the rest of the msg */ 	memcpy(new_buf+offset, orig+s_offset, len-s_offset);	new_buf[new_len]=0;	 /* send it! */	printf("Sending:\n%s.\n", new_buf);	printf("orig. len=%d, new_len=%d, via_len=%d, received_len=%d\n",			len, new_len, via_len, received_len);	to.sin_family = AF_INET;	to.sin_port = (re->port)?htons(re->port):htons(SIP_PORT);	/* if error try next ip address if possible */	if (re->ok==0){		if (re->host.h_addr_list[re->current_addr_idx+1])			re->current_addr_idx++;		re->ok=1;	}	/* ? not 64bit clean?*/	to.sin_addr.s_addr=*((long*)re->host.h_addr_list[re->current_addr_idx]);	re->tx++;	re->tx_bytes+=new_len;	if (udp_send(new_buf, new_len, &to, sizeof(to))==-1){			re->errors++;			re->ok=0;			goto error;	}	free(new_buf);	return 0;error:	free(new_buf);error1:	return -1;}