diff options
author | dillon <dillon@FreeBSD.org> | 2001-12-19 19:04:57 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2001-12-19 19:04:57 +0000 |
commit | de48df525fc8f2ca18d19cecaafcac3161fa5bf8 (patch) | |
tree | 9c73db933b8245a96832230b61946f6d86484c00 /sys/kern/subr_sbuf.c | |
parent | 3e097bafbac340e920002af83f4f0969e98af967 (diff) | |
download | FreeBSD-src-de48df525fc8f2ca18d19cecaafcac3161fa5bf8.zip FreeBSD-src-de48df525fc8f2ca18d19cecaafcac3161fa5bf8.tar.gz |
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
Diffstat (limited to 'sys/kern/subr_sbuf.c')
-rw-r--r-- | sys/kern/subr_sbuf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index ed04ad5..72e6522 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); } |