From 009b711834d26610d23d14bd8b7540eb69c836a7 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 15 Dec 2016 19:03:42 +0000 Subject: [PATCH] libdm: clear region table in dm_stats_list() Call _stats_regions_destroy() from dm_stats_list() if dms->regions is non-NULL. This avoids leaking any pool allocations and ensures the handle is in a known state: if an error occurs during the list, dms->regions will be NULL and the handle will appear empty. --- libdm/libdm-stats.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index 8d202d21c..39782446f 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -1083,6 +1083,9 @@ int dm_stats_list(struct dm_stats *dms, const char *program_id) if (!_stats_set_name_cache(dms)) return_0; + if (dms->regions) + _stats_regions_destroy(dms); + r = dm_snprintf(msg, sizeof(msg), "@stats_list %s", program_id); if (r < 0) {