--- pkg-config-0.22.orig/pkg.c +++ pkg-config-0.22/pkg.c @@ -34,6 +34,7 @@ #endif #include +#include #include #include #include @@ -203,16 +204,25 @@ else { char *filename = g_malloc (dirnamelen + 1 + len + 1); + struct stat statbuf; strncpy (filename, dirname, dirnamelen); filename[dirnamelen] = G_DIR_SEPARATOR; strcpy (filename + dirnamelen + 1, dent->d_name); + + /* Only add to hash if this stats as a regular file */ + if (stat(filename, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) + { + g_hash_table_insert (locations, pkgname, filename); + g_hash_table_insert (path_positions, pkgname, + GINT_TO_POINTER (scanned_dir_count)); - g_hash_table_insert (locations, pkgname, filename); - g_hash_table_insert (path_positions, pkgname, - GINT_TO_POINTER (scanned_dir_count)); - - debug_spew ("Will find package '%s' in file '%s'\n", - pkgname, filename); + debug_spew ("Will find package '%s' in file '%s'\n", + pkgname, filename); + } + else + { + g_free(filename); + } } } else