From a7d4334083344af3682d92e8fb92ae8468857514 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Tue, 10 Nov 2015 16:58:05 -0200 Subject: [PATCH] common/platform-linux: fix leaking on parse_mount_point_file error It could leaks a buffer. Signed-off-by: Bruno Dilly --- src/lib/common/sol-platform-linux-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/common/sol-platform-linux-common.c b/src/lib/common/sol-platform-linux-common.c index f50287b5f..4603edb4f 100644 --- a/src/lib/common/sol-platform-linux-common.c +++ b/src/lib/common/sol-platform-linux-common.c @@ -311,7 +311,7 @@ parse_mount_point_file(const char *file, struct sol_ptr_vector *vector) struct mntent mbuf; struct mntent *m; char strings[4096]; - struct sol_buffer *itr; + struct sol_buffer *itr, *buff = NULL; uint16_t i; FILE *tab = setmntent(file, "re"); @@ -327,7 +327,6 @@ parse_mount_point_file(const char *file, struct sol_ptr_vector *vector) } while ((m = getmntent_r(tab, &mbuf, strings, sizeof(strings)))) { - struct sol_buffer *buff = NULL; int r; buff = sol_buffer_new(); @@ -343,6 +342,7 @@ parse_mount_point_file(const char *file, struct sol_ptr_vector *vector) return 0; err: + sol_buffer_fini(buff); SOL_PTR_VECTOR_FOREACH_IDX (vector, itr, i) { sol_buffer_fini(itr); }