aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_sbuf.c
diff options
context:
space:
mode:
authorMatthew Dillon <dillon@FreeBSD.org>2001-12-19 19:04:57 +0000
committerMatthew Dillon <dillon@FreeBSD.org>2001-12-19 19:04:57 +0000
commita57094a011eefe38a814021b00fc20a9e3c1046f (patch)
tree9c73db933b8245a96832230b61946f6d86484c00 /sys/kern/subr_sbuf.c
parentdf6ee7b7a124b60db6c4efaf2c2ee1bc4ebb5357 (diff)
downloadsrc-a57094a011eefe38a814021b00fc20a9e3c1046f.tar.gz
src-a57094a011eefe38a814021b00fc20a9e3c1046f.zip
Calculate whether the sbuf is dynamic *before* bzero()ing the
structure. This fixes a serious memory leak in the sbuf code. MFC after: 3 days
Notes
Notes: svn path=/head/; revision=88219
Diffstat (limited to 'sys/kern/subr_sbuf.c')
-rw-r--r--sys/kern/subr_sbuf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c
index ed04ad57ba92..72e65227d12e 100644
--- a/sys/kern/subr_sbuf.c
+++ b/sys/kern/subr_sbuf.c
@@ -461,12 +461,15 @@ sbuf_len(struct sbuf *s)
void
sbuf_delete(struct sbuf *s)
{
+ int isdyn;
+
assert_sbuf_integrity(s);
/* don't care if it's finished or not */
if (SBUF_ISDYNAMIC(s))
SBFREE(s->s_buf);
+ isdyn = SBUF_ISDYNSTRUCT(s);
bzero(s, sizeof *s);
- if (SBUF_ISDYNSTRUCT(s))
+ if (isdyn)
SBFREE(s);
}