From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id 43662395C800; Tue, 3 Aug 2021 15:55:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43662395C800 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Siddhesh Poyarekar To: glibc-cvs@sourceware.org Subject: [glibc] gconv_parseconfdir: Fix memory leak X-Act-Checkin: glibc X-Git-Author: Siddhesh Poyarekar X-Git-Refname: refs/heads/master X-Git-Oldrev: b0234d79e7d82475d1666f25326ec045c045b3ed X-Git-Newrev: 5f9b78fe35d08739b6da1e5b356786d41116c108 Message-Id: <20210803155526.43662395C800@sourceware.org> Date: Tue, 3 Aug 2021 15:55:26 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 15:55:26 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5f9b78fe35d08739b6da1e5b356786d41116c108 commit 5f9b78fe35d08739b6da1e5b356786d41116c108 Author: Siddhesh Poyarekar Date: Tue Aug 3 21:10:20 2021 +0530 gconv_parseconfdir: Fix memory leak The allocated `conf` would leak if we have to skip over the file due to the underlying filesystem not supporting dt_type. Reviewed-by: Arjun Shankar Diff: --- iconv/gconv_parseconfdir.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h index a4153e54c6..2f062689ec 100644 --- a/iconv/gconv_parseconfdir.h +++ b/iconv/gconv_parseconfdir.h @@ -153,12 +153,11 @@ gconv_parseconfdir (const char *dir, size_t dir_len) struct stat64 st; if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) continue; - if (ent->d_type == DT_UNKNOWN - && (lstat64 (conf, &st) == -1 - || !S_ISREG (st.st_mode))) - continue; - found |= read_conf_file (conf, dir, dir_len); + if (ent->d_type != DT_UNKNOWN + || (lstat64 (conf, &st) != -1 && S_ISREG (st.st_mode))) + found |= read_conf_file (conf, dir, dir_len); + free (conf); } }