Coverity CID 1193: Add KASSERT before negative array deref.

This commit is contained in:
christos 2006-04-15 02:35:22 +00:00
parent 49cd195740
commit d3b0d78d54
1 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $ */
/* $NetBSD: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $ */
/*
* This file is derived from various .h and .c files from the zlib-1.0.4
* distribution by Jean-loup Gailly and Mark Adler, with some additions
@ -11,7 +11,7 @@
* - added inflateIncomp and deflateOutputPending
* - allow strm->next_out to be NULL, meaning discard the output
*
* $Id: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $
* $Id: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $
*/
/*
@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $");
#define NO_DUMMY_DECL
#define NO_ZCFUNCS
@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $");
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $ */
/* @(#) $Id: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $ */
#ifndef _Z_UTIL_H
#define _Z_UTIL_H
@ -295,7 +295,7 @@ void zcfree __P((voidpf opaque, voidpf ptr));
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $ */
/* @(#) $Id: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $ */
#ifndef _DEFLATE_H
#define _DEFLATE_H
@ -657,7 +657,7 @@ void _tr_stored_type_only __P((deflate_state *));
*
*/
/* @(#) $Id: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $ */
/* @(#) $Id: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $ */
/* #include "deflate.h" */
@ -2031,7 +2031,7 @@ local block_state deflate_slow(s, flush)
* Addison-Wesley, 1983. ISBN 0-201-06672-6.
*/
/* @(#) $Id: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $ */
/* @(#) $Id: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $ */
/* #define GEN_TREES_H */
@ -4768,6 +4768,7 @@ uIntf *v; /* working area: values in order of bit length */
/* backup over finished tables */
mask = (1 << w) - 1; /* needed on HP, cc -O bug */
KASSERT(h != -1);
while ((i & mask) != x[h])
{
h--; /* don't need to update q */
@ -5907,7 +5908,7 @@ void zcfree (opaque, ptr)
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id: zlib.c,v 1.23 2006/01/14 18:58:05 christos Exp $ */
/* @(#) $Id: zlib.c,v 1.24 2006/04/15 02:35:22 christos Exp $ */
/* #include "zlib.h" */