From c2be7c1b95b4d5aa7debad8f4e41c3611cde4057 Mon Sep 17 00:00:00 2001 From: Felix Moessbauer Date: Tue, 17 Oct 2023 12:34:28 +0200 Subject: [PATCH] libebgenv: fix memory leak in partition probing When probing partitions, the mountpoint string is allocated on the heap. Normally the mountpoint is freed during unmounting. But for partitions that are already mounted, we also need to free the mountpoint str. Signed-off-by: Felix Moessbauer [Jan: NULLify mountpoint to avoid double frees] Signed-off-by: Jan Kiszka --- env/env_config_file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/env/env_config_file.c b/env/env_config_file.c index c9cc99f..232c190 100644 --- a/env/env_config_file.c +++ b/env/env_config_file.c @@ -85,6 +85,9 @@ bool probe_config_file(CONFIG_PART *cfgpart) } if (do_unmount) { unmount_partition(cfgpart); + } else { + free(cfgpart->mountpoint); + cfgpart->mountpoint = NULL; } return result; }