summaryrefslogtreecommitdiff
path: root/libdm/libdm-stats.c
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2015-09-07 12:01:20 +0100
committerBryn M. Reeves <bmr@redhat.com>2015-09-07 12:01:20 +0100
commit0f5933ecc1bf792a404e2cdfa8a2eccf66b5b6e1 (patch)
treee8e9633a1d2ecf86846b866a5a54ef82374f3ec4 /libdm/libdm-stats.c
parente75b4bc2df7ce9bf3b3644fb0e6d9d52467adb8e (diff)
downloadlvm2-0f5933ecc1bf792a404e2cdfa8a2eccf66b5b6e1.tar.gz
libdm: handle pool errors in dm_histogram_to_string()
Diffstat (limited to 'libdm/libdm-stats.c')
-rw-r--r--libdm/libdm-stats.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 0655ac555..bb26c46a4 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -2222,7 +2222,8 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
/* Set bounds string to the empty string. */
bounds_buf[0] = '\0';
- dm_pool_begin_object(mem, 64);
+ if (!dm_pool_begin_object(mem, 64))
+ return_0;
for (bin = start; bin <= last; bin++) {
if (bounds) {
@@ -2277,9 +2278,13 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
goto_bad;
width = minwidth; /* re-set histogram column width. */
- dm_pool_grow_object(mem, buf, (size_t) len);
+ if (!dm_pool_grow_object(mem, buf, (size_t) len))
+ goto_bad;
}
- dm_pool_grow_object(mem, "\0", 1);
+
+ if (!dm_pool_grow_object(mem, "\0", 1))
+ goto_bad;
+
return (const char *) dm_pool_end_object(mem);
bad: