diff options
| author | Karel Zak <kzak@redhat.com> | 2025-03-25 12:14:14 +0100 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2025-04-03 14:12:27 +0200 |
| commit | 33ca468b67d34dead8fb8b41dc9f328971e5fe70 (patch) | |
| tree | f1f3cfb8c9efbed83b5da82d3443aa568b734c08 /disk-utils/cfdisk.c | |
| parent | 4b63ef9c6c9a6fe3d0381ba97af9ad6a738fd9c8 (diff) | |
| download | util-linux-33ca468b67d34dead8fb8b41dc9f328971e5fe70.tar.gz | |
cfdisk: fix memory leak and possible NULL dereference [gcc-analyzer]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/cfdisk.c')
| -rw-r--r-- | disk-utils/cfdisk.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index d0bb57aaf1..e8a8b959a0 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -947,6 +947,7 @@ static void menu_set_title(struct cfdisk_menu *m, const char *title) m->width = len + MENU_TITLE_PADDING; str = xstrdup(title); } + free(m->title); m->title = str; } @@ -2173,7 +2174,8 @@ static int ui_create_label(struct cfdisk *cf) nitems = fdisk_get_nlabels(cf->cxt); cm = xcalloc(nitems + 1, sizeof(struct cfdisk_menuitem)); - while (fdisk_next_label(cf->cxt, &lb) == 0) { + while (fdisk_next_label(cf->cxt, &lb) == 0 && i < nitems) { + if (fdisk_label_is_disabled(lb) || fdisk_label_get_type(lb) == FDISK_DISKLABEL_BSD) continue; |
