Browse code

- 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 authored on 05/12/2005 17:32:17
Showing 5 changed files
... ...
@@ -693,7 +693,7 @@ int do_action(struct action* a, struct sip_msg* msg)
693 693
 			} else if (a->p2_type == ACTION_ST) {
694 694
 				flags = a->p1.attr->type;
695 695
 				name = a->p1.attr->name;
696
-				if (&a->p2.data) {
696
+				if (a->p2.data) {
697 697
 					value.n = run_actions((struct action*)a->p2.data, msg);
698 698
 				} else {
699 699
 					value.n = -1;
... ...
@@ -682,7 +682,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
682 682
 {
683 683
 	struct cell*  p_cell;
684 684
 	unsigned int hash_index   = 0;
685
-	int entry_label  = 0;
685
+	unsigned int entry_label  = 0;
686 686
 	unsigned int branch_id    = 0;
687 687
 	char  *hashi, *branchi, *p, *n;
688 688
 	int hashl, branchl;
... ...
@@ -376,6 +376,9 @@ inline static int comp_str(int op, str* left, int rtype, union exp_op* r)
376 376
 	avp_t* avp;
377 377
 	int ret;
378 378
 	char backup;
379
+	regex_t* re;
380
+	
381
+	right=0; /* warning fix */
379 382
 	
380 383
 	if (rtype == AVP_ST) {
381 384
 		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)
419 419
 			backup=left->s[left->len];
420 420
 			left->s[left->len]='\0';
421 421
 			if (rtype == AVP_ST) {
422
-				regex_t* re;
423 422
 				     /* For AVPs we need to compile the RE on the fly */
424 423
 				re=(regex_t*)pkg_malloc(sizeof(regex_t));
425 424
 				if (re==0){
426 425
 					LOG(L_CRIT, "ERROR: comp_strstr: memory allocation"
427 426
 					    " failure\n");
427
+					left->s[left->len] = backup;
428 428
 					goto error;
429 429
 				}
430 430
 				if (regcomp(re, right->s, REG_EXTENDED|REG_NOSUB|REG_ICASE)) {
431 431
 					pkg_free(re);
432
+					left->s[left->len] = backup;
432 433
 					goto error;
433 434
 				}				
434 435
 				ret=(regexec(re, left->s, 0, 0, 0)==0);
436
+				regfree(re);
435 437
 				pkg_free(re);
436 438
 			} else {
437 439
 				ret=(regexec(r->re, left->s, 0, 0, 0)==0);
... ...
@@ -782,7 +782,7 @@ error:
782 782
 }
783 783
 
784 784
 
785
-int delete_avp(unsigned short flags, int_str name)
785
+void delete_avp(unsigned short flags, int_str name)
786 786
 {
787 787
 	struct search_state st;
788 788
 	avp_t* avp;
... ...
@@ -138,7 +138,7 @@ int add_avp(unsigned short flags, int_str name, int_str val);
138 138
 int add_avp_list(avp_list_t* list, unsigned short flags, int_str name, int_str val);
139 139
 
140 140
 /* Delete avps with given type and name */
141
-int delete_avp(unsigned short flags, int_str name);
141
+void delete_avp(unsigned short flags, int_str name);
142 142
 
143 143
 /* search functions */
144 144
 avp_t *search_first_avp( unsigned short flags, int_str name,