From 7ab4820af7b39e12023ab3aee74cb7e66e97f786 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 8 Dec 2022 16:28:13 +1300 Subject: [PATCH] [ruby/logger] Only assign to `@filename` if the path is valid. (https://github.com/ruby/logger/pull/81) https://github.com/ruby/logger/commit/b41d7c699c --- lib/logger/log_device.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb index 8683328a5e..84277a2656 100644 --- a/lib/logger/log_device.rb +++ b/lib/logger/log_device.rb @@ -79,8 +79,10 @@ class Logger def set_dev(log) if log.respond_to?(:write) and log.respond_to?(:close) @dev = log - if log.respond_to?(:path) - @filename = log.path + if log.respond_to?(:path) and path = log.path + if File.exist?(path) + @filename = path + end end else @dev = open_logfile(log)