From clodder@acm.org, via OpenBSD: add a check for memory allocation
failure.
This commit is contained in:
parent
39c13cd5ee
commit
8c2a3a235c
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.186 2003-02-14 07:48:25 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.187 2003-03-08 08:23:47 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -225,6 +225,8 @@ newchunk(n)
|
||||||
bpf_error("out of memory");
|
bpf_error("out of memory");
|
||||||
size = CHUNK0SIZE << k;
|
size = CHUNK0SIZE << k;
|
||||||
cp->m = (void *)malloc(size);
|
cp->m = (void *)malloc(size);
|
||||||
|
if (cp->m == NULL)
|
||||||
|
bpf_error("out of memory");
|
||||||
memset((char *)cp->m, 0, size);
|
memset((char *)cp->m, 0, size);
|
||||||
cp->n_left = size;
|
cp->n_left = size;
|
||||||
if (n > size)
|
if (n > size)
|
||||||
|
|
Reference in New Issue