From e4b64e4c07d5e87d6ee06f3b821860b6175d8655 Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Fri, 11 Jan 2019 15:37:25 +0000
Subject: [PATCH] dialog.c: cleanup -Wnull-dereference warning
Found by GCC8
dialog.c:136:17: error: 'w' may be used uninitialized in this function [-Werror=maybe-uninitialized]
while ((widget_get_state (w, WST_DISABLED) || !widget_get_options (w, WOP_SELECTABLE))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dialog.c:134:15: error: null pointer dereference [-Werror=null-dereference]
w = WIDGET (l->data);
dialog.c:139:25: error: potential null pointer dereference [-Werror=null-dereference]
widget_select (l->data);
~^~~~~~
Signed-off-by: Andreas Mohr <and@gmx.li>
---
lib/widget/dialog.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c
index cddd27a0e..45b177c93 100644
a
|
b
|
dlg_select_next_or_prev (WDialog * h, gboolean next) |
126 | 126 | if (h->widgets != NULL && h->current != NULL) |
127 | 127 | { |
128 | 128 | GList *l = h->current; |
129 | | Widget *w; |
| 129 | Widget *w = NULL; |
130 | 130 | |
131 | 131 | do |
132 | 132 | { |
133 | | l = dlg_get_next_or_prev_of (l, next); |
134 | | w = WIDGET (l->data); |
| 133 | if ((l = dlg_get_next_or_prev_of (l, next)) != NULL) |
| 134 | w = WIDGET (l->data); |
135 | 135 | } |
136 | 136 | while ((widget_get_state (w, WST_DISABLED) || !widget_get_options (w, WOP_SELECTABLE)) |
137 | 137 | && l != h->current); |
138 | 138 | |
139 | | widget_select (l->data); |
| 139 | if (l != NULL) |
| 140 | widget_select (l->data); |
140 | 141 | } |
141 | 142 | } |
142 | 143 | |