[PATCH twm 2/3] Add sanity checking to avoid a possible NULL dereference
Jeremy Huddleston
jeremyhu at apple.com
Wed May 11 22:43:50 PDT 2011
menus.c:934:26: warning: Access to field 'fore' results in a dereference of a null pointer (loaded from variable 'cur')
cur->hi_back = cur->fore = f3.pixel;
~~~ ^
Found-by: clang static analyzer
Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
src/menus.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/menus.c b/src/menus.c
index 34a3c8e..395426f 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -920,7 +920,7 @@ MakeMenu(MenuRoot *mr)
b3.flags = DoRed | DoGreen | DoBlue;
num -= 1;
- for (i = 0, cur = start->next; i < num; i++, cur = cur->next)
+ for (i = 0, cur = start->next; i < num && cur; i++, cur = cur->next)
{
f3.red += fred;
f3.green += fgreen;
--
1.7.4.4
More information about the xorg-devel
mailing list