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