Ver Fonte

htable: init allocated memory after checking parameter

- avoid useless operation and extra check for leak
Daniel-Constantin Mierla há 11 anos atrás
pai
commit
9f042bb279
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      modules/htable/htable.c

+ 1 - 1
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");