From 54a35ff48b600cd59b715b6e5aea4e69de1b995f Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Mon, 14 Oct 2019 23:29:19 -0300 Subject: lib: fix route map northbound memory leak Keep a list of hook contexts used by northbound so we don't lose the pointer when free()ing the route map index entry data. Signed-off-by: Rafael Zalamena --- lib/routemap.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/routemap.c') diff --git a/lib/routemap.c b/lib/routemap.c index 5369fa771f..912cf28202 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -909,6 +909,7 @@ static struct route_map_index *route_map_index_new(void) new = XCALLOC(MTYPE_ROUTE_MAP_INDEX, sizeof(struct route_map_index)); new->exitpolicy = RMAP_EXIT; /* Default to Cisco-style */ + TAILQ_INIT(&new->rhclist); QOBJ_REG(new, route_map_index); return new; } @@ -924,6 +925,10 @@ 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 northbound hook contexts. */ + while (!TAILQ_EMPTY(&index->rhclist)) + routemap_hook_context_free(TAILQ_FIRST(&index->rhclist)); + /* Free route match. */ while ((rule = index->match_list.head) != NULL) route_map_rule_delete(&index->match_list, rule); -- cgit v1.2.3