ソースを参照

htable: init allocated memory after checking parameter

- avoid useless operation and extra check for leak
Daniel-Constantin Mierla 11 年 前
コミット
9f042bb279
1 ファイル変更1 行追加1 行削除
  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");