94084c
commit 3a48da47a91ccc6f5de260574809e7a44551b876
94084c
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
94084c
Date:   Tue Aug 3 21:10:20 2021 +0530
94084c
94084c
    gconv_parseconfdir: Fix memory leak
94084c
    
94084c
    The allocated `conf` would leak if we have to skip over the file due
94084c
    to the underlying filesystem not supporting dt_type.
94084c
    
94084c
    Reviewed-by: Arjun Shankar <arjun@redhat.com>
94084c
    (cherry picked from commit 5f9b78fe35d08739b6da1e5b356786d41116c108)
94084c
94084c
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
94084c
index a4153e54c6d43797..2f062689ecc72749 100644
94084c
--- a/iconv/gconv_parseconfdir.h
94084c
+++ b/iconv/gconv_parseconfdir.h
94084c
@@ -153,12 +153,11 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
94084c
 	      struct stat64 st;
94084c
 	      if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
94084c
 		continue;
94084c
-	      if (ent->d_type == DT_UNKNOWN
94084c
-		  && (lstat64 (conf, &st) == -1
94084c
-		      || !S_ISREG (st.st_mode)))
94084c
-		continue;
94084c
 
94084c
-	      found |= read_conf_file (conf, dir, dir_len);
94084c
+	      if (ent->d_type != DT_UNKNOWN
94084c
+		  || (lstat64 (conf, &st) != -1 && S_ISREG (st.st_mode)))
94084c
+		found |= read_conf_file (conf, dir, dir_len);
94084c
+
94084c
 	      free (conf);
94084c
 	    }
94084c
 	}