Skip to content

Commit

Permalink
libebgenv: fix memory leak in partition probing
Browse files Browse the repository at this point in the history
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 <[email protected]>
[Jan: NULLify mountpoint to avoid double frees]
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed Oct 17, 2023
1 parent 261e8c2 commit c2be7c1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions env/env_config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c2be7c1

Please sign in to comment.