From e2bea6a0278f182f9cc8b7bac660da49d24d2e50 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 2 Jun 2006 19:21:52 +0000 Subject: Coverity #925: Pointer "file" dereferenced before NULL check --- ChangeLog | 5 +++++ parse.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1075e26..374ef52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-06-02 Alan Coopersmith + + * parse.c (slookup): + Coverity #925: Pointer "file" dereferenced before NULL check + 2005-12-14 Kevin E. Martin * configure.ac: diff --git a/parse.c b/parse.c index 935c61d..5248293 100644 --- a/parse.c +++ b/parse.c @@ -429,9 +429,14 @@ struct symtab ** slookup(char *symbol, struct inclist *file) { register int first = 0; - register int last = file->i_ndefs - 1; + register int last; - if (file) while (last >= first) + if (file == NULL) + return NULL; + + last = file->i_ndefs - 1; + + while (last >= first) { /* Fast inline binary search */ register char *s1; -- cgit v1.2.3