From fee0c5a6dc9314724b60f1e2057b764d45256e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 14 Sep 2014 00:15:35 +0200 Subject: Fix clang static analyzer warnings --- editor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'editor.c') diff --git a/editor.c b/editor.c index 9d520d8..455ed5b 100644 --- a/editor.c +++ b/editor.c @@ -66,7 +66,7 @@ static void editor_windows_arrange_horizontal(Editor *ed) { int n = 0, x = 0, y = 0; for (EditorWin *win = ed->windows; win; win = win->next) n++; - int height = ed->height / n; + int height = ed->height / MAX(1, n); for (EditorWin *win = ed->windows; win; win = win->next) { editor_window_resize(win, ed->width, win->next ? height : ed->height - y); editor_window_move(win, x, y); @@ -78,7 +78,7 @@ static void editor_windows_arrange_vertical(Editor *ed) { int n = 0, x = 0, y = 0; for (EditorWin *win = ed->windows; win; win = win->next) n++; - int width = ed->width / n - 1; + int width = (ed->width / MAX(1, n)) - 1; for (EditorWin *win = ed->windows; win; win = win->next) { editor_window_resize(win, win->next ? width : ed->width - x, ed->height); editor_window_move(win, x, y); @@ -126,6 +126,8 @@ static void editor_window_split_internal(Editor *ed, const char *filename) { } if (sel) { EditorWin *win = editor_window_new_text(ed, sel->text); + if (!win) + return; win->text = sel->text; window_syntax_set(win->win, window_syntax_get(sel->win)); window_cursor_to(win->win, window_cursor_get(sel->win)); -- cgit v1.2.3