瀏覽代碼

- fixed some warnings
- fixed typo in action.c
- fixed dynamic regex not regfreed and backup char not restored on error in
route.c

Andrei Pelinescu-Onciul 20 年之前
父節點
當前提交
3d942590eb
共有 5 個文件被更改,包括 10 次插入5 次删除
  1. 1 1
      action.c
  2. 1 1
      modules/tm/t_lookup.c
  3. 6 1
      route.c
  4. 1 1
      usr_avp.c
  5. 1 1
      usr_avp.h

+ 1 - 1
action.c

@@ -693,7 +693,7 @@ int do_action(struct action* a, struct sip_msg* msg)
 			} else if (a->p2_type == ACTION_ST) {
 			} else if (a->p2_type == ACTION_ST) {
 				flags = a->p1.attr->type;
 				flags = a->p1.attr->type;
 				name = a->p1.attr->name;
 				name = a->p1.attr->name;
-				if (&a->p2.data) {
+				if (a->p2.data) {
 					value.n = run_actions((struct action*)a->p2.data, msg);
 					value.n = run_actions((struct action*)a->p2.data, msg);
 				} else {
 				} else {
 					value.n = -1;
 					value.n = -1;

+ 1 - 1
modules/tm/t_lookup.c

@@ -682,7 +682,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 {
 {
 	struct cell*  p_cell;
 	struct cell*  p_cell;
 	unsigned int hash_index   = 0;
 	unsigned int hash_index   = 0;
-	int entry_label  = 0;
+	unsigned int entry_label  = 0;
 	unsigned int branch_id    = 0;
 	unsigned int branch_id    = 0;
 	char  *hashi, *branchi, *p, *n;
 	char  *hashi, *branchi, *p, *n;
 	int hashl, branchl;
 	int hashl, branchl;

+ 6 - 1
route.c

@@ -376,6 +376,9 @@ inline static int comp_str(int op, str* left, int rtype, union exp_op* r)
 	avp_t* avp;
 	avp_t* avp;
 	int ret;
 	int ret;
 	char backup;
 	char backup;
+	regex_t* re;
+	
+	right=0; /* warning fix */
 	
 	
 	if (rtype == AVP_ST) {
 	if (rtype == AVP_ST) {
 		avp = search_first_avp(r->attr->type, r->attr->name, &val, 0);
 		avp = search_first_avp(r->attr->type, r->attr->name, &val, 0);
@@ -419,19 +422,21 @@ inline static int comp_str(int op, str* left, int rtype, union exp_op* r)
 			backup=left->s[left->len];
 			backup=left->s[left->len];
 			left->s[left->len]='\0';
 			left->s[left->len]='\0';
 			if (rtype == AVP_ST) {
 			if (rtype == AVP_ST) {
-				regex_t* re;
 				     /* For AVPs we need to compile the RE on the fly */
 				     /* For AVPs we need to compile the RE on the fly */
 				re=(regex_t*)pkg_malloc(sizeof(regex_t));
 				re=(regex_t*)pkg_malloc(sizeof(regex_t));
 				if (re==0){
 				if (re==0){
 					LOG(L_CRIT, "ERROR: comp_strstr: memory allocation"
 					LOG(L_CRIT, "ERROR: comp_strstr: memory allocation"
 					    " failure\n");
 					    " failure\n");
+					left->s[left->len] = backup;
 					goto error;
 					goto error;
 				}
 				}
 				if (regcomp(re, right->s, REG_EXTENDED|REG_NOSUB|REG_ICASE)) {
 				if (regcomp(re, right->s, REG_EXTENDED|REG_NOSUB|REG_ICASE)) {
 					pkg_free(re);
 					pkg_free(re);
+					left->s[left->len] = backup;
 					goto error;
 					goto error;
 				}				
 				}				
 				ret=(regexec(re, left->s, 0, 0, 0)==0);
 				ret=(regexec(re, left->s, 0, 0, 0)==0);
+				regfree(re);
 				pkg_free(re);
 				pkg_free(re);
 			} else {
 			} else {
 				ret=(regexec(r->re, left->s, 0, 0, 0)==0);
 				ret=(regexec(r->re, left->s, 0, 0, 0)==0);

+ 1 - 1
usr_avp.c

@@ -782,7 +782,7 @@ error:
 }
 }
 
 
 
 
-int delete_avp(unsigned short flags, int_str name)
+void delete_avp(unsigned short flags, int_str name)
 {
 {
 	struct search_state st;
 	struct search_state st;
 	avp_t* avp;
 	avp_t* avp;

+ 1 - 1
usr_avp.h

@@ -138,7 +138,7 @@ int add_avp(unsigned short flags, int_str name, int_str val);
 int add_avp_list(avp_list_t* list, unsigned short flags, int_str name, int_str val);
 int add_avp_list(avp_list_t* list, unsigned short flags, int_str name, int_str val);
 
 
 /* Delete avps with given type and name */
 /* Delete avps with given type and name */
-int delete_avp(unsigned short flags, int_str name);
+void delete_avp(unsigned short flags, int_str name);
 
 
 /* search functions */
 /* search functions */
 avp_t *search_first_avp( unsigned short flags, int_str name,
 avp_t *search_first_avp( unsigned short flags, int_str name,