From cc45875e0d2af0b53100ec78364dc51b39a12ac9 Mon Sep 17 00:00:00 2001
From: Rafael Zalamena <rzalamena@opensourcerouting.org>
Date: Mon, 6 Jul 2020 11:39:27 -0300
Subject: [PATCH] lib: fix route map description memory leak

Route map entries are not getting a chance to call `description` string
deallocation on shutdown or when the parent entry is destroyed, so lets
add a code to handle this in the `route_map_index_delete` function.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit f0951335830203426074ddca4317f84b477e4afb)
---
 lib/routemap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/routemap.c b/lib/routemap.c
index 3d69a3495a..3b45133450 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -971,6 +971,9 @@ void route_map_index_delete(struct route_map_index *index, int notify)
 		zlog_debug("Deleting route-map %s sequence %d",
 			   index->map->name, index->pref);
 
+	/* Free route map entry description. */
+	XFREE(MTYPE_TMP, index->description);
+
 	/* Free route map northbound hook contexts. */
 	while ((rhc = TAILQ_FIRST(&index->rhclist)) != NULL)
 		routemap_hook_context_free(rhc);
