From 2c3e626a0db9661e0f45aa67449b0342650f2c1b Mon Sep 17 00:00:00 2001 From: David Bright Date: Wed, 20 Feb 2019 22:05:44 +0000 Subject: [PATCH] Complete fix for CID 1007454, CID 1007453: Resource leak in newsyslog The result of a strdup() was stored in a global variable and not freed before program exit. This is a follow-up to r343906. That change attempted to plug these resource leaks but managed to miss a code path on which the leak still occurs. Plug the leak on that path, too. MFC after: 3 days Sponsored by: Dell EMC Isilon --- usr.sbin/newsyslog/newsyslog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index 5826e8e2d40d..66d4a2c62db4 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -793,6 +793,9 @@ usage(void) fprintf(stderr, "usage: newsyslog [-CFNPnrsv] [-a directory] [-d directory] [-f config_file]\n" " [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n"); + /* Free global dynamically-allocated storage. */ + free(timefnamefmt); + free(requestor); exit(1); }