From 11dd877484b3af8f524d4a1afcc3d59ac90743a9 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 18 Oct 2017 23:01:07 +0200 Subject: [PATCH] initctl: Fix possible divide by zero, found by Coverity Scan Signed-off-by: Joachim Nilsson --- src/serv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/serv.c b/src/serv.c index 0a0b0192..64fe864a 100644 --- a/src/serv.c +++ b/src/serv.c @@ -86,6 +86,9 @@ static void do_list(const char *heading, const char *path) printf("\e[1m%s\e[0m\n", buf); width = calc_width(gl.gl_pathv, gl.gl_pathc); + if (width <= 0) + goto done; + num = (screen_cols - 2) / width; if ((num - 1) * 2 + num * width > screen_cols) num--;