Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpcap avoid malloc(0). from kame changes, sync with t...
details: https://anonhg.NetBSD.org/src/rev/069008dfbb3c
branches: trunk
changeset: 484898:069008dfbb3c
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Apr 14 14:17:13 2000 +0000
description:
avoid malloc(0). from kame changes, sync with tcpdump.org.
diffstat:
lib/libpcap/optimize.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diffs (54 lines):
diff -r 580d4f3f3d48 -r 069008dfbb3c lib/libpcap/optimize.c
--- a/lib/libpcap/optimize.c Fri Apr 14 14:15:41 2000 +0000
+++ b/lib/libpcap/optimize.c Fri Apr 14 14:17:13 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: optimize.c,v 1.9 1999/07/02 16:03:41 simonb Exp $ */
+/* $NetBSD: optimize.c,v 1.10 2000/04/14 14:17:13 itojun Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
@@ -28,7 +28,7 @@
static const char rcsid[] =
"@(#) Header: optimize.c,v 1.60 96/09/26 23:28:14 leres Exp (LBL)";
#else
-__RCSID("$NetBSD: optimize.c,v 1.9 1999/07/02 16:03:41 simonb Exp $");
+__RCSID("$NetBSD: optimize.c,v 1.10 2000/04/14 14:17:13 itojun Exp $");
#endif
#endif
@@ -1901,7 +1901,7 @@
int slen;
u_int off;
int extrajmps; /* number of extra jumps inserted */
- struct slist **offset;
+ struct slist **offset = NULL;
if (p == 0 || isMarked(p))
return (1);
@@ -1919,10 +1919,12 @@
p->offset = dst - fstart;
/* generate offset[] for convenience */
- offset = (struct slist **)calloc(sizeof(struct slist *), slen);
- if (!offset) {
- bpf_error("not enough core");
- /*NOTREACHED*/
+ if (slen) {
+ offset = (struct slist **)calloc(sizeof(struct slist *), slen);
+ if (!offset) {
+ bpf_error("not enough core");
+ /*NOTREACHED*/
+ }
}
src = p->stmts;
for (off = 0; off < slen && src; off++) {
@@ -1998,7 +2000,8 @@
++dst;
++off;
}
- free(offset);
+ if (offset)
+ free(offset);
#ifdef BDEBUG
bids[dst - fstart] = p->id + 1;
Home |
Main Index |
Thread Index |
Old Index