From 08f75d3a9661c6c32800e1b4f150626200b889d9 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 27 Jan 2013 13:50:30 -0800 Subject: [PATCH] Avoid NULL pointer dereference in xf86TokenToOptinfo if token not found Reported by parfait 1.1 code analyzer: Error: Null pointer dereference (CWE 476) Read from null pointer 'p' at line 746 of hw/xfree86/common/xf86Option.c in function 'xf86TokenToOptName'. Function 'xf86TokenToOptinfo' may return constant 'NULL' at line 721, called at line 745. Null pointer introduced at line 721 in function 'xf86TokenToOptinfo'. Signed-off-by: Alan Coopersmith Reviewed-by: Peter Hutterer --- hw/xfree86/common/xf86Option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index 40c9d15f4..607c33354 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -743,7 +743,7 @@ xf86TokenToOptName(const OptionInfoRec * table, int token) const OptionInfoRec *p; p = xf86TokenToOptinfo(table, token); - return p->name; + return p ? p->name : NULL; } Bool