Browse Source

Merge branch 'master' of ssh://[email protected]/sip-router

* 'master' of ssh://[email protected]/sip-router:
  * Fixed pua module memory leak.  Credits to Anca Vamanu.
  fix k bug #2790184, crash related to uninitialized match_callid parameter
Miklos Tirpak 16 years ago
parent
commit
a2ad989437
2 changed files with 12 additions and 8 deletions
  1. 6 6
      modules_k/pua/add_events.c
  2. 6 2
      modules_k/registrar/lookup.c

+ 6 - 6
modules_k/pua/add_events.c

@@ -114,10 +114,11 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 		LM_ERR("while extracting tuple node\n");
 		goto error;
 	}
+	tuple= *(tuple_param);
+
 	tuple_id= xmlNodeGetAttrContentByName(node, "id");
 	if(tuple_id== NULL)
 	{
-		tuple= *(tuple_param);
 
 		if(tuple== NULL)	// generate a tuple_id
 		{
@@ -144,7 +145,6 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 			alloc_tuple= 1;
 
 			LM_DBG("allocated tuple_id\n\n");
-
 		}
 		else
 		{
@@ -152,7 +152,7 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 			tuple_id_len= tuple->len;
 			memcpy(tuple_id, tuple->s, tuple_id_len);
 			tuple_id[tuple_id_len]= '\0';
-		}	
+		}
 		/* add tuple id */
 		if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
 		{
@@ -184,10 +184,10 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 			}
 			memcpy(tuple->s, tuple_id, tuple_id_len);
 			tuple->len= tuple_id_len;
+			*tuple_param= tuple;
 			alloc_tuple= 1;
-
-		}	
-	}	
+		}
+	}
 
 	node= xmlDocGetNodeByName(doc, "person", NULL);
 	if(node)

+ 6 - 2
modules_k/registrar/lookup.c

@@ -179,6 +179,7 @@ int registered(struct sip_msg* _m, char* _t, char* _s)
 	urecord_t* r;
 	ucontact_t* ptr;
 	int res;
+	int_str match_callid;
 
 	if (_m->new_uri.s) uri = _m->new_uri;
 	else uri = _m->first_line.u.request.uri;
@@ -199,12 +200,15 @@ int registered(struct sip_msg* _m, char* _t, char* _s)
 
 	if (res == 0) {
 		
-		int_str match_callid;
 		if (reg_callid_avp_name.n) {
 			struct usr_avp *avp =
 				search_first_avp( reg_callid_avp_type, reg_callid_avp_name, &match_callid, 0);
 			if (!(avp && is_avp_str_val(avp)))
-				match_callid=(int_str)0;
+				match_callid.n = 0;
+				match_callid.s.s = NULL;
+		} else {
+			match_callid.n = 0;
+			match_callid.s.s = NULL;
 		}
 
 		for (ptr = r->contacts; ptr; ptr = ptr->next) {