Browse code

Merge remote branch 'origin/sr_3.0'

Weekly update with the latest sr_3.0 fixes.

* origin/sr_3.0:
core: fix fixup_spve_* reuse after free
Remove obsolete gen_ha1.
modules_k/permissions: Increased version number of 'trusted' table
lib/srdb1/schema/trusted.xml: forgot to increase version number
lib/srdb1/schema/trusted.xml: increased tag length from 32 to 64 chars
makefile: support self-installing utils, extra cfgs a.s.o.
core: fix memleak in fixup_free*
core: fix cfg_update() on config error 2nd try
userblacklist(k): gcc 2.95 compile fixes
statistics(k): minor warning in printf fmt
siputils(k): gcc 2.95 compile fixes
registrar(k): gcc 2.95 compile fixes
pua_mi: gcc 2.95 compile fixes
cfgutils(k): gcc 2.95 compile fixes
lcr: compile & warning fixes for gcc 2.95
db_postgres: compile fixes for gcc 2.95
db_mysql: compile fix for gcc 2.95
compile: don't warn on old gcc versions
utils/sercmd: Fixed include paths also in sr_3.0 branch.

Conflicts:
Makefile

Andrei Pelinescu-Onciul authored on 15/10/2009 18:01:11
Showing 19 changed files
... ...
@@ -339,15 +339,27 @@ cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
339 339
 #modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
340 340
 
341 341
 
342
-# which utils need compilation (directory path) and which to install
343
-# (full path including file name)
344
-utils_compile=	utils/sercmd
345
-utils_bin_install=	# sercmd is now installed by ctl
346
-utils_script_install=
347 342
 
348
-# This is the list of files to be installed into the arch-independent
349
-# shared directory (by default /usr/local/share/$(MAIN_NAME))
350
-share_install=
343
+# list of utils directories that should be compiled by make utils
344
+C_COMPILE_UTILS=	utils/sercmd
345
+# list of binaries that should be installed alongside
346
+# (they should be created after make utils, see C_COMPILE_UTILS)
347
+C_INSTALL_BIN=	# sercmd is now installed by ctl
348
+
349
+# which utils know to install themselves and should be installed
350
+# along the core (list of utils directories)
351
+C_INSTALL_UTILS=
352
+# list of scripts that should be installed along the core 
353
+# (here a script is something that doesn't have a Makefile)
354
+C_INSTALL_SCRIPTS=
355
+# list of extra configs that should be installed along the core
356
+# Note: all the paths of the form /usr/*lib/$(CFG_NAME)/<module_dir>
357
+# will be updated to the directory where the modules will be installed.
358
+C_INSTALL_CFGS=
359
+# list of files that should be installed in the arch-independent 
360
+# directory (by default /usr/local/share/$(MAIN_NAME)))
361
+C_INSTALL_SHARE=
362
+
351 363
 
352 364
 
353 365
 
... ...
@@ -635,7 +647,7 @@ $(extra_objs):
635 635
 
636 636
 .PHONY: utils
637 637
 utils:
638
-	@for r in $(utils_compile) "" ; do \
638
+	@for r in $(C_COMPILE_UTILS) "" ; do \
639 639
 		if [ -n "$$r" ]; then \
640 640
 			$(call oecho, "" ;) \
641 641
 			$(call oecho, "" ;) \
... ...
@@ -801,6 +813,30 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
801 801
 			mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
802 802
 				$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
803 803
 		fi
804
+		# other configs
805
+		@for r in $(C_INSTALL_CFGS) ; do \
806
+			if [ -n "$$r" ]; then \
807
+				if [ -f "$$r" ]; then \
808
+					n=`basename "$$r"` ; \
809
+					sed $(foreach m,$(modules_dirs),\
810
+							-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
811
+						< "$$r" \
812
+						> "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
813
+					chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
814
+					if [ -z "${skip_cfg_install}" -a \
815
+							! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; \
816
+					then \
817
+						mv -f "$(cfg_prefix)/$(cfg_dir)$$n.sample" \
818
+								"$(cfg_prefix)/$(cfg_dir)$$n"; \
819
+					fi ; \
820
+				else \
821
+					echo "ERROR: $$r not found" ; \
822
+					if [ ${err_fail} = 1 ] ; then \
823
+						exit 1; \
824
+					fi ; \
825
+				fi ; \
826
+			fi ; \
827
+		done; true
804 828
 		# radius dictionary
805 829
 		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
806 830
 		$(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
... ...
@@ -811,7 +847,7 @@ install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
811 811
 
812 812
 
813 813
 install-share: $(share_prefix)/$(share_dir)
814
-	@for r in $(share_install) "" ; do \
814
+	@for r in $(C_INSTALL_SHARE) "" ; do \
815 815
 		if [ -n "$$r" ]; then \
816 816
 			if [ -f "$$r" ]; then \
817 817
 				$(call try_err, $(INSTALL_TOUCH) \
... ...
@@ -835,7 +871,7 @@ install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
835 835
 install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
836 836
 
837 837
 install-utils: utils $(bin_prefix)/$(bin_dir)
838
-	@for r in $(utils_bin_install) "" ; do \
838
+	@for r in $(C_INSTALL_BIN) "" ; do \
839 839
 		if [ -n "$$r" ]; then \
840 840
 			if [ -f "$$r" ]; then \
841 841
 				$(call try_err, $(INSTALL_TOUCH) \
... ...
@@ -850,7 +886,7 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
850 850
 			fi ;\
851 851
 		fi ; \
852 852
 	done; true
853
-	@for r in $(utils_script_install) "" ; do \
853
+	@for r in $(C_INSTALL_SCRIPTS) "" ; do \
854 854
 		if [ -n "$$r" ]; then \
855 855
 			if [ -f "$$r" ]; then \
856 856
 				$(call try_err, $(INSTALL_TOUCH) \
... ...
@@ -865,6 +901,9 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
865 865
 			fi ;\
866 866
 		fi ; \
867 867
 	done; true
868
+	@for ut in $(C_INSTALL_UTILS) ; do \
869
+		$(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
870
+	done; true
868 871
 
869 872
 
870 873
 install-modules-all: install-every-module install-every-module-doc
... ...
@@ -52,7 +52,7 @@
52 52
 
53 53
 #else /* __GNUC__ */
54 54
 
55
-#warning "No compiler optimizations supported try gcc 4.x"
55
+/* #warning "No compiler optimizations supported try gcc 4.x" */
56 56
 #define likely(expr) (expr)
57 57
 #define unlikely(expr) (expr)
58 58
 
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 <table id="trusted" xmlns:db="http://docbook.org/ns/docbook">
11 11
     <name>trusted</name>
12
-    <version>4</version>
12
+    <version>5</version>
13 13
     <type db="mysql">&MYSQL_TABLE_TYPE;</type>
14 14
     <description>
15 15
         <db:para>This table is used by the permissions module to determine if a call has the appropriate permission to be established. More information about the permissions module can be found at: &KAMAILIO_MOD_DOC;permissions.html
... ...
@@ -53,7 +53,7 @@
53 53
     <column>
54 54
         <name>tag</name>
55 55
         <type>string</type>
56
-        <size>32</size>
56
+        <size>64</size>
57 57
         <null/>
58 58
         <description>Tag</description>
59 59
     </column>
... ...
@@ -1556,6 +1556,7 @@ int main_loop()
1556 1556
 #endif
1557 1557
 		/* init cfg, but without per child callbacks support */
1558 1558
 		cfg_child_no_cb_init();
1559
+		cfg_ok=1;
1559 1560
 
1560 1561
 #ifdef EXTRA_DEBUG
1561 1562
 		for (r=0; r<*process_count; r++){
... ...
@@ -2096,7 +2097,6 @@ try_again:
2096 2096
 		LOG(L_CRIT, "could not declare the core configuration\n");
2097 2097
 		goto error;
2098 2098
 	}
2099
-	cfg_ok=1;
2100 2099
 #ifdef USE_TCP
2101 2100
 	if (tcp_register_cfg()){
2102 2101
 		LOG(L_CRIT, "could not register the tcp configuration\n");
... ...
@@ -204,7 +204,6 @@ FIXUP_F2FP_T(igp_pvar_pvar, 1, 3, 1, FPARAM_INT|FPARAM_PVS, FPARAM_PVS)
204 204
 		int ret; \
205 205
 		char * bkp; \
206 206
 		fparam_t* fp; \
207
-		bkp=*param; \
208 207
 		if (param_no<=(no1)){ \
209 208
 			if ((ret=fix_param_types(FPARAM_PVE, param))<0){ \
210 209
 				ERR("Cannot convert function parameter %d to" #type2 "\n", \
... ...
@@ -213,6 +212,8 @@ FIXUP_F2FP_T(igp_pvar_pvar, 1, 3, 1, FPARAM_INT|FPARAM_PVS, FPARAM_PVS)
213 213
 			} else{ \
214 214
 				fp=(fparam_t*)*param; \
215 215
 				if ((ret==0) && (fp->v.pve->spec.getf==0)){ \
216
+					bkp=fp->orig; \
217
+					fp->orig=0; /* make sure orig string is not freed */ \
216 218
 					fparam_free_contents(fp); \
217 219
 					pkg_free(fp); \
218 220
 					*param=bkp; \
... ...
@@ -136,9 +136,10 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
136 136
  */
137 137
 void db_mysql_free_connection(struct pool_con* con)
138 138
 {
139
+	struct my_con * _c;
140
+	
139 141
 	if (!con) return;
140 142
 
141
-	struct my_con * _c;
142 143
 	_c = (struct my_con*) con;
143 144
 
144 145
 	if (_c->res) mysql_free_result(_c->res);
... ...
@@ -108,9 +108,10 @@ struct pg_con* db_postgres_new_connection(struct db_id* id)
108 108
 void db_postgres_free_connection(struct pool_con* con)
109 109
 {
110 110
 
111
+	struct pg_con * _c;
112
+	
111 113
 	if (!con) return;
112 114
 
113
-	struct pg_con * _c;
114 115
 	_c = (struct pg_con*)con;
115 116
 
116 117
 	if (_c->res) {
... ...
@@ -277,14 +277,13 @@ int pg_con_connect(db_con_t* con)
277 277
 	/* Override default notice processor */
278 278
 	PQsetNoticeProcessor(pcon->con, notice_processor, 0);
279 279
 	
280
-	DBG("postgres: Connected. Protocol version=%d, Server version=%d\n", 
281
-	    PQprotocolVersion(pcon->con),
282 280
 #ifdef HAVE_PGSERVERVERSION
283
-	    PQserverVersion(pcon->con)
281
+	DBG("postgres: Connected. Protocol version=%d, Server version=%d\n", 
282
+	    PQprotocolVersion(pcon->con), PQserverVersion(pcon->con));
284 283
 #else
285
-	    0
284
+	DBG("postgres: Connected. Protocol version=%d, Server version=%d\n", 
285
+	    PQprotocolVersion(pcon->con), 0 );
286 286
 #endif
287
-	    );
288 287
 
289 288
 	ret = timestamp_format(pcon->con);
290 289
 	if (ret == 1 || ret == -1) {
... ...
@@ -399,6 +399,7 @@ static int mod_init(void)
399 399
     str s;
400 400
     unsigned short avp_flags;
401 401
     unsigned int i;
402
+    db1_con_t* dbh;
402 403
 
403 404
 	if(register_mi_mod(exports.name, mi_cmds)!=0)
404 405
 	{
... ...
@@ -556,7 +557,6 @@ static int mod_init(void)
556 556
     }
557 557
 
558 558
     /* Check table version */
559
-    db1_con_t* dbh;
560 559
     if (lcr_dbf.init==0){
561 560
 	LM_CRIT("unbound database\n");
562 561
 	return -1;
... ...
@@ -1277,7 +1277,7 @@ int reload_gws_and_lcrs(int lcr_id)
1277 1277
 	    first_gw = find_first_gw(gw_grps, grp_cnt, grp_id);
1278 1278
 	    if (first_gw == 0) {
1279 1279
 		LM_ERR("gw grp_id <%u> of prefix <%.*s> has no gateways\n",
1280
-		       grp_id, prefix_len, prefix);
1280
+		       grp_id, (int)prefix_len, prefix);
1281 1281
 		goto lcr_err;
1282 1282
 	    }
1283 1283
 	    if ((VAL_NULL(ROW_VALUES(row) + 3) == 1) ||
... ...
@@ -1892,7 +1892,7 @@ static int generate_uris(char *r_uri, str *r_uri_user, unsigned int *r_uri_len,
1892 1892
     destroy_avp(gu_avp);
1893 1893
 	
1894 1894
     LM_DBG("r_uri <%.*s>, dst_uri <%.*s>\n",
1895
-	   *r_uri_len, r_uri, *dst_uri_len, dst_uri);
1895
+	   (int)*r_uri_len, r_uri, (int)*dst_uri_len, dst_uri);
1896 1896
 
1897 1897
     return 1;
1898 1898
 }
... ...
@@ -488,11 +488,6 @@ error:
488 488
   */
489 489
 static int MD5File(char *dest, const char *file_name)
490 490
 {
491
-	if (!dest || !file_name) {
492
-		LM_ERR("invalid parameter value\n");
493
-		return -1;
494
-	}
495
-
496 491
 	MD5_CTX context;
497 492
 	FILE *input;
498 493
 	unsigned char buffer[32768];
... ...
@@ -500,6 +495,12 @@ static int MD5File(char *dest, const char *file_name)
500 500
 	unsigned int counter, size;
501 501
 	
502 502
 	struct stat stats;
503
+	
504
+	if (!dest || !file_name) {
505
+		LM_ERR("invalid parameter value\n");
506
+		return -1;
507
+	}
508
+
503 509
     if (stat(file_name, &stats) != 0) {
504 510
 		LM_ERR("could not stat file %s\n", file_name);
505 511
 		return -1;
... ...
@@ -588,12 +589,13 @@ static int get_prob(struct sip_msg *bar, char *foo1, char *foo2)
588 588
 
589 589
 static int rand_event(struct sip_msg *bar, char *foo1, char *foo2)
590 590
 {
591
+	double tmp;
591 592
 	/* most of the time this will be disabled completly. Tis will also fix the
592 593
 	 * problem with the corner cases if rand() returned zero or RAND_MAX */
593 594
 	if ((*probability) == 0) return -1;
594 595
 	if ((*probability) == 100) return 1;
595 596
 
596
-	double tmp = ((double) rand() / RAND_MAX);
597
+	tmp = ((double) rand() / RAND_MAX);
597 598
 	LM_DBG("generated random %f\n", tmp);
598 599
 	if (tmp < ((double) (*probability) / 100)) {
599 600
 		LM_DBG("return true\n");
... ...
@@ -40,7 +40,7 @@
40 40
 #include "../../parser/parse_from.h"
41 41
 #include "../../usr_avp.h"
42 42
 
43
-#define TABLE_VERSION 4
43
+#define TABLE_VERSION 5
44 44
 
45 45
 struct trusted_list ***hash_table;     /* Pointer to current hash table pointer */
46 46
 struct trusted_list **hash_table_1;   /* Pointer to hash table 1 */
... ...
@@ -84,9 +84,10 @@ struct module_exports exports= {
84 84
  */
85 85
 static int mod_init(void)
86 86
 {
87
-	LM_DBG("...\n");
88 87
 	bind_pua_t bind_pua;
89 88
 	
89
+	LM_DBG("...\n");
90
+	
90 91
 	if(register_mi_mod(exports.name, mi_cmds)!=0)
91 92
 	{
92 93
 		LM_ERR("failed to register MI commands\n");
... ...
@@ -50,8 +50,6 @@
50 50
 int extract_aor(str* _uri, str* _a)
51 51
 {
52 52
 	static char aor_buf[MAX_AOR_LEN];
53
-	memset(aor_buf, 0, MAX_AOR_LEN);
54
-
55 53
 	str tmp;
56 54
 	struct sip_uri puri;
57 55
 	int user_len;
... ...
@@ -59,6 +57,7 @@ int extract_aor(str* _uri, str* _a)
59 59
 	struct usr_avp *avp;
60 60
 	str *uri;
61 61
 
62
+	memset(aor_buf, 0, MAX_AOR_LEN);
62 63
 	if (aor_avp_name.n!=0) {
63 64
 		avp = search_first_avp( aor_avp_type, aor_avp_name, &avp_val, 0);
64 65
 		if (avp && is_avp_str_val(avp)) {
... ...
@@ -210,6 +210,7 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
210 210
 	
211 211
 	
212 212
 #ifdef DEBUG
213
+	str* ruri;
213 214
 	fprintf (stdout,"---START--------DECODE CONTACT HEADER-----------------\n");
214 215
 #endif
215 216
 
... ...
@@ -227,9 +228,9 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
227 227
 
228 228
 #ifdef DEBUG
229 229
 	fprintf (stdout,"Using separator %c\n",separator);
230
-	str* ruri;
231 230
 	ruri = GET_RURI(msg);
232
-	fprintf (stdout,"[len = %d]New uri is->%*.s\n",ruri->len,ruri->len,ruri->s);
231
+	fprintf (stdout,"[len = %d]New uri is->%.*s\n",
232
+			ruri->len,ruri->len,ruri->s);
233 233
 	ruri = &msg->first_line.u.request.uri;
234 234
 	fprintf (stdout, "INITIAL.s=[%.*s]\n", ruri->len, ruri->s);
235 235
 #endif
... ...
@@ -192,10 +192,10 @@ static void remove_timeout(unsigned int index)
192 192
 static void insert(str callid)
193 193
 {
194 194
 	unsigned int index = hash(callid.s, callid.len) & HASHTABLEMASK;
195
-
195
+	struct ring_record_t* rr;
196
+	
196 197
 	remove_timeout(index);
197
-
198
-	struct ring_record_t* rr = shm_malloc(sizeof(struct ring_record_t));
198
+	rr = shm_malloc(sizeof(struct ring_record_t));
199 199
 	assert(rr);
200 200
 
201 201
 	rr->next = NULL;
... ...
@@ -224,10 +224,11 @@ static void insert(str callid)
224 224
 static int contains(str callid)
225 225
 {
226 226
 	unsigned int index = hash(callid.s, callid.len) & HASHTABLEMASK;
227
+	struct ring_record_t* rr;
227 228
 
228 229
 	remove_timeout(index);
229 230
 
230
-	struct ring_record_t* rr = (*hashtable)[index].head;
231
+	rr = (*hashtable)[index].head;
231 232
 	while (rr) {
232 233
 		if (strncmp(rr->callid, callid.s, callid.len) == 0) return 1;
233 234
 		rr = rr->next;
... ...
@@ -245,25 +246,38 @@ static int conv183(struct sip_msg *msg)
245 245
 	/* content-length and content-type headers are removed */
246 246
 	char *del1_start = strstr(msg->buf, "Content-Length:");
247 247
 	char *del2_start = strstr(msg->buf, "Content-Type:");
248
+	char *del1_end;
249
+	char *del2_end;
250
+	char *eoh;
251
+	char *chunk1_start;
252
+	int chunk1_len;
253
+	char *chunk1_dst;
254
+	char *chunk2_start;
255
+	int chunk2_len;
256
+	char *chunk2_dst;
257
+	char *chunk3_start;
258
+	int chunk3_len;
259
+	char *chunk3_dst;
260
+	
248 261
 	if (del1_start>del2_start) {
249 262
 		char *tmp = del1_start;
250 263
 		del1_start = del2_start;
251 264
 		del2_start = tmp;
252 265
 	}
253 266
 
254
-	char *del1_end = NULL;
267
+	del1_end = NULL;
255 268
 	if (del1_start) {
256 269
 		del1_end = strstr(del1_start, "\r\n");
257 270
 		if (del1_end) del1_end+=2;
258 271
 	}
259
-	char *del2_end = NULL;
272
+	del2_end = NULL;
260 273
 	if (del2_start) {
261 274
 		del2_end = strstr(del2_start, "\r\n");
262 275
 		if (del2_end) del2_end+=2;
263 276
 	}
264 277
 
265 278
 	/* 180 message does not need session description */
266
-	char *eoh = strstr(msg->buf, "\r\n\r\n");
279
+	eoh = strstr(msg->buf, "\r\n\r\n");
267 280
 	if (eoh) eoh+=2;
268 281
 
269 282
 	if ((!del1_start) || (!del2_start) || (!del1_end) || (!del2_end) || (!eoh)) {
... ...
@@ -288,17 +302,17 @@ static int conv183(struct sip_msg *msg)
288 288
 	strncpy(msg->first_line.u.reply.reason.s, "Ringing                                           ", msg->first_line.u.reply.reason.len);
289 289
 
290 290
 	/* calculate addresses of chunks to be moved */
291
-	char *chunk1_start = del1_end;
292
-	int chunk1_len     = del2_start-del1_end;
293
-	char *chunk1_dst   = del1_start;
291
+	chunk1_start = del1_end;
292
+	chunk1_len     = (int)(long)(del2_start-del1_end);
293
+	chunk1_dst   = del1_start;
294 294
 
295
-	char *chunk2_start = del2_end;
296
-	int chunk2_len     = eoh-del2_end;
297
-	char *chunk2_dst   = chunk1_dst+chunk1_len;
295
+	chunk2_start = del2_end;
296
+	chunk2_len     = (int)(long)(eoh-del2_end);
297
+	chunk2_dst   = chunk1_dst+chunk1_len;
298 298
 
299
-	char *chunk3_start = "Content-Length: 0\r\n\r\n";
300
-	int chunk3_len     = strlen(chunk3_start);
301
-	char *chunk3_dst   = chunk2_dst+chunk2_len;
299
+	chunk3_start = "Content-Length: 0\r\n\r\n";
300
+	chunk3_len     = strlen(chunk3_start);
301
+	chunk3_dst   = chunk2_dst+chunk2_len;
302 302
 
303 303
 	// move chunks
304 304
 	memmove(chunk1_dst, chunk1_start, chunk1_len);
... ...
@@ -123,7 +123,7 @@ static int fixup_stat(void** param, int param_no)
123 123
 		/* is it pv? */
124 124
 		if (s.s[0]=='$') {
125 125
 			if (fixup_pvar_null(param, 1)!=0) {
126
-				LM_ERR("invalid pv %.s as parameter\n",s.s);
126
+				LM_ERR("invalid pv %s as parameter\n",s.s);
127 127
 				return E_CFG;
128 128
 			}
129 129
 			sopv->pv = (pv_spec_t*)(*param);
... ...
@@ -46,6 +46,10 @@ int db_build_userbl_tree(const str *username, const str *domain, const str *tabl
46 46
 	db_key_t key[2] = { &userblacklist_username_col, &userblacklist_domain_col };
47 47
 
48 48
 	db_val_t val[2];
49
+	db1_res_t *res;
50
+	int i;
51
+	int n = 0;
52
+	void *nodeflags;
49 53
 	VAL_TYPE(val) = VAL_TYPE(val + 1) = DB1_STR;
50 54
 	VAL_NULL(val) = VAL_NULL(val + 1) = 0;
51 55
 	VAL_STR(val).s = username->s;
... ...
@@ -53,10 +57,6 @@ int db_build_userbl_tree(const str *username, const str *domain, const str *tabl
53 53
 	VAL_STR(val + 1).s = domain->s;
54 54
 	VAL_STR(val + 1).len = domain->len;
55 55
 
56
-	db1_res_t *res;
57
-	int i;
58
-	int n = 0;
59
-	void *nodeflags;
60 56
 	
61 57
 	if (userblacklist_dbf.use_table(userblacklist_dbh, table) < 0) {
62 58
 		LM_ERR("cannot use table '%.*s'.\n", table->len, table->s);
... ...
@@ -380,6 +380,8 @@ static int check_blacklist_fixup(void **arg, int arg_no)
380 380
 {
381 381
 	char *table = (char *)(*arg);
382 382
 	struct dtrie_node_t *node = NULL;
383
+	struct check_blacklist_fs_t *new_arg;
384
+	
383 385
 	if (arg_no != 1) {
384 386
 		LM_ERR("wrong number of parameters\n");
385 387
 		return -1;
... ...
@@ -402,7 +404,7 @@ static int check_blacklist_fixup(void **arg, int arg_no)
402 402
 		return -1;
403 403
 	}
404 404
 
405
-	struct check_blacklist_fs_t *new_arg = (struct check_blacklist_fs_t*)pkg_malloc(sizeof(struct check_blacklist_fs_t));
405
+	new_arg = pkg_malloc(sizeof(struct check_blacklist_fs_t));
406 406
 	if (!new_arg) {
407 407
 		PKG_MEM_ERROR;
408 408
 		return -1;
... ...
@@ -475,15 +477,17 @@ static int reload_sources(void)
475 475
 {
476 476
 	int result = 0;
477 477
 	str tmp;
478
+	struct source_t *src;
479
+	int n;
478 480
 
479 481
 	/* critical section start: avoids dirty reads when updating d-tree */
480 482
 	lock_get(lock);
481 483
 
482
-	struct source_t *src = sources->head;
484
+	src = sources->head;
483 485
 	while (src) {
484 486
 		tmp.s = src->table;
485 487
 		tmp.len = strlen(src->table);
486
-		int n = db_reload_source(&tmp, src->dtrie_root);
488
+		n = db_reload_source(&tmp, src->dtrie_root);
487 489
 		if (n < 0) {
488 490
 			LM_ERR("cannot reload source from '%.*s'\n", tmp.len, tmp.s);
489 491
 			result = -1;
... ...
@@ -1195,7 +1195,7 @@ void fparam_free_contents(fparam_t* fp)
1195 1195
 		case FPARAM_INT:
1196 1196
 		case FPARAM_STR:
1197 1197
 			/* nothing to do */
1198
-			return;
1198
+			break;
1199 1199
 		case FPARAM_REGEX:
1200 1200
 			if (fp->v.regex){
1201 1201
 				regfree(fp->v.regex);
... ...
@@ -1231,6 +1231,10 @@ void fparam_free_contents(fparam_t* fp)
1231 1231
 			}
1232 1232
 			break;
1233 1233
 	}
1234
+	if (fp->orig){
1235
+		pkg_free(fp->orig);
1236
+		fp->orig=0;
1237
+	}
1234 1238
 }
1235 1239
 
1236 1240