Browse code

core: init allocated memory in str_hash_alloc()

- removed unused pointer shifting in dset.c
- small reworking of lval_assign()

(cherry picked from commit ba9f2b5af9cabd61f67ceedb8feab6bd7bc6526d)

Daniel-Constantin Mierla authored on 05/04/2021 10:02:20
Showing 3 changed files
... ...
@@ -860,7 +860,6 @@ int msg_get_src_addr(sip_msg_t *msg, str *uri, int mode)
860 860
 		p += TRANSPORT_PARAM_LEN;
861 861
 
862 862
 		memcpy(p, proto.s, proto.len);
863
-		p += proto.len;
864 863
 	}
865 864
 
866 865
 	uri->s = buf;
... ...
@@ -380,7 +380,7 @@ int lval_assign(struct run_act_ctx* h, struct sip_msg* msg,
380 380
 	struct rvalue* rv;
381 381
 	int ret;
382 382
 
383
-	ret=0;
383
+	ret=-1;
384 384
 	rv=rval_expr_eval(h, msg, rve);
385 385
 	if (unlikely(rv==0)){
386 386
 		LM_ERR("rval expression evaluation failed (%d,%d-%d,%d)\n",
... ...
@@ -404,9 +404,7 @@ int lval_assign(struct run_act_ctx* h, struct sip_msg* msg,
404 404
 		LM_ERR("assignment failed at pos: (%d,%d-%d,%d)\n",
405 405
 			rve->fpos.s_line, rve->fpos.s_col,
406 406
 			rve->fpos.e_line, rve->fpos.e_col);
407
-	}
408
-	else
409
-	{
407
+	} else {
410 408
 		if(unlikely(_log_assign_action!=NULL))
411 409
 			_log_assign_action(msg, lv);
412 410
 	}
... ...
@@ -414,5 +412,5 @@ int lval_assign(struct run_act_ctx* h, struct sip_msg* msg,
414 412
 	return ret;
415 413
 error:
416 414
 	if (rv) rval_destroy(rv);
417
-	return -1;
415
+	return ret;
418 416
 }
... ...
@@ -56,7 +56,7 @@ struct str_hash_table{
56 56
 /* returns 0 on success, <0 on failure */
57 57
 inline static int str_hash_alloc(struct str_hash_table* ht, int size)
58 58
 {
59
-	ht->table=(struct str_hash_head*)pkg_malloc(sizeof(struct str_hash_head)*size);
59
+	ht->table=(struct str_hash_head*)pkg_mallocxz(sizeof(struct str_hash_head)*size);
60 60
 	if (ht->table==0) {
61 61
 		PKG_MEM_ERROR;
62 62
 		return -1;