diff options
author | marcel <marcel@FreeBSD.org> | 2013-12-18 04:52:30 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2013-12-18 04:52:30 +0000 |
commit | cec28dc92dc9b76f7fd200ecacbc480ba3fd4e64 (patch) | |
tree | 2671ac69b56f9171001b844f7e3ea3b2142e8cae /lib/libstand | |
parent | 9ca55833b64341e1f2e98b057767806ce3483918 (diff) | |
download | FreeBSD-src-cec28dc92dc9b76f7fd200ecacbc480ba3fd4e64.zip FreeBSD-src-cec28dc92dc9b76f7fd200ecacbc480ba3fd4e64.tar.gz |
Clear f_rabuf after freeing the memory it points to. This prevents a
possible double free.
Obtained from: Juniper Networks, Inc.
Diffstat (limited to 'lib/libstand')
-rw-r--r-- | lib/libstand/close.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libstand/close.c b/lib/libstand/close.c index 61b1b0d..939f025 100644 --- a/lib/libstand/close.c +++ b/lib/libstand/close.c @@ -75,8 +75,10 @@ close(int fd) errno = EBADF; return (-1); } - if (f->f_rabuf != NULL) + if (f->f_rabuf != NULL) { free(f->f_rabuf); + f->f_rabuf = NULL; + } if (!(f->f_flags & F_RAW) && f->f_ops) err1 = (f->f_ops->fo_close)(f); if (!(f->f_flags & F_NODEV) && f->f_dev) |