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