Coverity CID 1206: Confusion between && and || leads to indexing an array

with negative index.
This commit is contained in:
christos 2006-04-30 23:56:42 +00:00
parent 1af32ba03a
commit f5c3fa40c3
1 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: unifdef.c,v 1.12 2003/08/07 11:16:55 agc Exp $ */
/* $NetBSD: unifdef.c,v 1.13 2006/04/30 23:56:42 christos Exp $ */
/*
* Copyright (c) 1985, 1993
@ -77,7 +77,7 @@ static const char copyright[] =
#endif
#ifdef __IDSTRING
__IDSTRING(Berkeley, "@(#)unifdef.c 8.1 (Berkeley) 6/6/93");
__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.12 2003/08/07 11:16:55 agc Exp $");
__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.13 2006/04/30 23:56:42 christos Exp $");
__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.161 2003/07/01 15:32:48 fanf2 Exp $");
#endif
#endif /* not lint */
@ -712,7 +712,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp)
return (LT_IF);
cp = skipcomment(cp);
sym = findsym(cp);
if (sym < 0 && !symlist)
if (sym < 0 || !symlist)
return (LT_IF);
*valp = (value[sym] != NULL);
cp = skipsym(cp);
@ -723,7 +723,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp)
} else if (!endsym(*cp)) {
debug("eval%d symbol", ops - eval_ops);
sym = findsym(cp);
if (sym < 0 && !symlist)
if (sym < 0 || !symlist)
return (LT_IF);
if (value[sym] == NULL)
*valp = 0;