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