From 983d2efd201a744b938622d1564002a524fcf9f9 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Wed, 18 Dec 2013 04:52:30 +0000 Subject: [PATCH] Clear f_rabuf after freeing the memory it points to. This prevents a possible double free. Obtained from: Juniper Networks, Inc. --- lib/libstand/close.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libstand/close.c b/lib/libstand/close.c index 61b1b0d99ffe..939f025b8fd0 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)