Browse code

avp: free allocated variable in case of error

Daniel-Constantin Mierla authored on 08/10/2019 10:31:39
Showing 1 changed files
... ...
@@ -1380,7 +1380,7 @@ static int attr_hdr_body2attrs2(struct sip_msg* msg, char* header_, char* prefix
1380 1380
 static int attr_hdr_body2attrs_fixup(void **param, int param_no)
1381 1381
 {
1382 1382
 	char *c, *params;
1383
-	hdr_name_t *h;
1383
+	hdr_name_t *h = NULL;
1384 1384
 	int n;
1385 1385
 	str *s;
1386 1386
 	if(param_no == 1) {
... ...
@@ -1427,6 +1427,7 @@ static int attr_hdr_body2attrs_fixup(void **param, int param_no)
1427 1427
 						LOG(L_ERR, "attr_hdr_body2attrs_fixup: bad field param "
1428 1428
 								"modifier near '%s'\n",
1429 1429
 								params);
1430
+						pkg_free(h);
1430 1431
 						return E_CFG;
1431 1432
 				}
1432 1433
 				params++;
... ...
@@ -1434,6 +1435,7 @@ static int attr_hdr_body2attrs_fixup(void **param, int param_no)
1434 1434
 			if(!h->val_types) {
1435 1435
 				LOG(L_ERR, "attr_hdr_body2attrs_fixup: no field param modifier "
1436 1436
 						"specified\n");
1437
+				pkg_free(h);
1437 1438
 				return E_CFG;
1438 1439
 			}
1439 1440
 		} else {