]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cfdisk: fix division by zero [clang-analyze]
authorKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2014 11:25:46 +0000 (13:25 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2014 11:25:46 +0000 (13:25 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/cfdisk.c

index 0e4638f102404416b02bea18b92e8504bc354b04..b79579ee41488b64e9c11bc1d29eedfab7ee8bbf 100644 (file)
@@ -796,6 +796,9 @@ static size_t menuitem_get_line(struct cfdisk *cf, size_t idx)
                size_t len = m->width + 4 + MENU_PADDING;       /* item width */
                size_t items = COLS / len;                      /* items per line */
 
+               if (items == 0)
+                       return 0;
+
                return MENU_START_LINE + ((idx / items));
        }
 }
@@ -814,6 +817,9 @@ static int menuitem_get_column(struct cfdisk *cf, size_t idx)
                                COLS % len :                            /* - multi-line menu */
                                COLS - (cf->menu->nitems * len);        /* - one line menu */
 
+               if (items == 0)
+                       return 0;                                       /* hmm... no space */
+
                extra += MENU_PADDING;          /* add padding after last item to extra */
 
                if (idx < items)