summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2016-12-15 19:03:42 +0000
committerBryn M. Reeves <bmr@redhat.com>2016-12-18 20:44:31 +0000
commit009b711834d26610d23d14bd8b7540eb69c836a7 (patch)
tree214bf762248f87c90871a5e04c04af00f9b3ae16
parent8d6ac1c3ba2ee72e9832383609b6ff030d9883ce (diff)
downloadlvm2-009b711834d26610d23d14bd8b7540eb69c836a7.tar.gz
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.
-rw-r--r--libdm/libdm-stats.c3
1 files changed, 3 insertions, 0 deletions
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) {