8000 cfdisk: fix memory leak and possible NULL dereference [gcc-analyzer] · util-linux/util-linux@9a918da · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a918da

Browse files
committed
cfdisk: fix memory leak and possible NULL dereference [gcc-analyzer]
Signed-off-by: Karel Zak <kzak@redhat.com> (cherry picked from commit 33ca468)
1 parent 5566da3 commit 9a918da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

disk-utils/cfdisk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ static void menu_set_title(struct cfdisk_menu *m, const char *title)
947947
m->width = len + MENU_TITLE_PADDING;
948948
str = xstrdup(title);
949949
}
950+
free(m->title);
950951
m->title = str;
951952
}
952953

@@ -2173,7 +2174,8 @@ static int ui_create_label(struct cfdisk *cf)
21732174
nitems = fdisk_get_nlabels(cf->cxt);
21742175
cm = xcalloc(nitems + 1, sizeof(struct cfdisk_menuitem));
21752176

2176-
while (fdisk_next_label(cf->cxt, &lb) == 0) {
2177+
while (fdisk_next_label(cf->cxt, &lb) == 0 && i < nitems) {
2178+
21772179
if (fdisk_label_is_disabled(lb) ||
21782180
fdisk_label_get_type(lb) == FDISK_DISKLABEL_BSD)
21792181
continue;

0 commit comments

Comments
 (0)
0