Merge pull request #20377 from Homebrew/fix-linkage-checker-file-descriptors
Fix file descriptor leak in Linux LD library path parsing
This commit is contained in:
commit
a729c533fd
@ -50,10 +50,17 @@ module OS
|
|||||||
conf_file = Pathname(conf_path)
|
conf_file = Pathname(conf_path)
|
||||||
return [] unless conf_file.exist?
|
return [] unless conf_file.exist?
|
||||||
|
|
||||||
|
@library_paths_cache ||= T.let({}, T.nilable(T::Hash[String, T::Array[String]]))
|
||||||
|
cache_key = conf_file.to_s
|
||||||
|
if (cached_library_path_contents = @library_paths_cache[cache_key])
|
||||||
|
return cached_library_path_contents
|
||||||
|
end
|
||||||
|
|
||||||
paths = Set.new
|
paths = Set.new
|
||||||
directory = conf_file.realpath.dirname
|
directory = conf_file.realpath.dirname
|
||||||
|
|
||||||
conf_file.readlines.each do |line|
|
conf_file.open("r") do |file|
|
||||||
|
file.each_line do |line|
|
||||||
# Remove comments and leading/trailing whitespace
|
# Remove comments and leading/trailing whitespace
|
||||||
line.strip!
|
line.strip!
|
||||||
line.sub!(/\s*#.*$/, "")
|
line.sub!(/\s*#.*$/, "")
|
||||||
@ -71,8 +78,9 @@ module OS
|
|||||||
paths << line
|
paths << line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
paths.to_a
|
@library_paths_cache[cache_key] = paths.to_a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user