[sr-dev] git:master: htable: init allocated memory after checking parameter

Daniel-Constantin Mierla miconda at gmail.com
Mon Apr 21 22:00:30 CEST 2014


Module: sip-router
Branch: master
Commit: 9f042bb2798f29d476148ab2887a05709d5258fc
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9f042bb2798f29d476148ab2887a05709d5258fc

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Apr 21 21:52:16 2014 +0200

htable: init allocated memory after checking parameter

- avoid useless operation and extra check for leak

---

 modules/htable/htable.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/modules/htable/htable.c b/modules/htable/htable.c
index 7270416..63262c0 100644
--- a/modules/htable/htable.c
+++ b/modules/htable/htable.c
@@ -266,12 +266,12 @@ static int fixup_ht_key(void** param, int param_no)
 	pv_spec_t *sp;
 	str s;
 
-	sp = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
 	if(param_no != 1)
 	{
 		LM_ERR("invalid parameter number %d\n", param_no);
 		return -1;
 	}
+	sp = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
 	if (sp == 0)
 	{
 		LM_ERR("no pkg memory left\n");




More information about the sr-dev mailing list