From 47a945278019cf4a6a38e0431ca6f4b8e7b6f5e3 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Mon, 12 Oct 2015 11:21:39 -0500
Subject: [PATCH] config.c: Fix off-nominal memory leak.

Change-Id: I06e346e9a5c63cc5071e7eda537310c4b43bffe0
---
 main/config.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/main/config.c b/main/config.c
index 5ced524d11..6f6f7cac12 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1659,6 +1659,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
 		/* If there are options or categories to inherit from, process them now */
 		if (c) {
 			if (!(cur = strchr(c, ')'))) {
+				ast_category_destroy(newcat);
 				ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile);
 				return -1;
 			}
@@ -1687,6 +1688,9 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
 
 					base = ast_category_get(cfg, cur, "TEMPLATES=include");
 					if (!base) {
+						if (newcat) {
+							ast_category_destroy(newcat);
+						}
 						ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile);
 						return -1;
 					}
-- 
GitLab