summaryrefslogtreecommitdiff
path: root/test/socket
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-11-23 13:55:15 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2025-11-23 13:55:15 +0900
commitbeb85e7eeee4163cd45b69645a60cdb942f72c05 (patch)
treed27290773e8a32861c03ebe7801e5201508fb9ff /test/socket
parenta7f948c32c169ceabb5719f0328e594759c73cd8 (diff)
[Bug #21705] Fix segfaults on Windows
It should check the type of the argument and coercion before converting the encoding.
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_unix.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 0d284b2926..e239e3935b 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -293,14 +293,18 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
File.unlink path if path && File.socket?(path)
end
- def test_open_nul_byte
- tmpfile = Tempfile.new("s")
- path = tmpfile.path
- tmpfile.close(true)
- assert_raise(ArgumentError) {UNIXServer.open(path+"\0")}
- assert_raise(ArgumentError) {UNIXSocket.open(path+"\0")}
- ensure
- File.unlink path if path && File.socket?(path)
+ def test_open_argument
+ assert_raise(TypeError) {UNIXServer.new(nil)}
+ assert_raise(TypeError) {UNIXServer.new(1)}
+ Tempfile.create("s") do |s|
+ path = s.path
+ s.close
+ File.unlink(path)
+ assert_raise(ArgumentError) {UNIXServer.open(path+"\0")}
+ assert_raise(ArgumentError) {UNIXSocket.open(path+"\0")}
+ arg = Struct.new(:to_path).new(path)
+ assert_equal(path, UNIXServer.open(arg) { |server| server.path })
+ end
end
def test_addr