From 02f145f175894399fed33992e4e7e5a87d7e7a2a Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 1 Aug 2014 23:15:29 -0700 Subject: Avoid null pointer use if malloc() fails Error: Null pointer dereference (CWE 476) Read from null pointer str at line 282 of handle.c in function 'parse_number'. Function copy_to_scratch may return constant 'NULL' at line 98, called at line 875 in function 'do_pointer'. Constant 'NULL' passed into function parse_number, argument str, from call at line 876. Null pointer introduced at line 98 in function 'copy_to_scratch'. [ This bug was found by the Parfait 1.4.0 bug checking tool. http://labs.oracle.com/pls/apex/f?p=labs:49:::::P49_PROJECT_ID:13 ] Signed-off-by: Alan Coopersmith --- handle.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'handle.c') diff --git a/handle.c b/handle.c index 3f05a46..240018e 100644 --- a/handle.c +++ b/handle.c @@ -873,6 +873,9 @@ do_pointer(char *line, int len) return; } strval = copy_to_scratch(line, n); + if (strval == NULL) + /* copy_to_scratch already printed error message */ + return; ok = parse_number (strval, &val); if (!ok || val >= MAXBUTTONCODES) { badmsg ("value %s given for buttons list", strval); -- cgit v1.2.3