From 0d533ed5fbbd794a2427675d0c665d3bd96e3508 Mon Sep 17 00:00:00 2001 From: Robin Hahling Date: Fri, 25 Oct 2013 12:15:37 +0200 Subject: [PATCH 4/4] Fix memory leak in df(1) Fix a memory leak in makenetvfslist which would occur when a previous call to strdup fails and the function returns on error. The simple fix is a call to free(3) to free memory allocated to listptr before returning. --- bin/df/df.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/df/df.c b/bin/df/df.c index 1e2ac65..a930642 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -600,6 +600,7 @@ makenetvfslist(void) listptr[cnt++] = strdup(ptr->vfc_name); if (listptr[cnt-1] == NULL) { warnx("malloc failed"); + free(listptr); return (NULL); } } -- 1.8.4