Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions ext/openssl/ossl_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,14 +2080,13 @@ ossl_ssl_write_internal_safe(VALUE _args)
static VALUE
ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
{
VALUE args[3] = {self, str, opts};
int state;
str = StringValue(str);

StringValue(str);
int frozen = RB_OBJ_FROZEN(str);
if (!frozen) {
str = rb_str_locktmp(str);
rb_str_locktmp(str);
}
int state;
VALUE args[3] = {self, str, opts};
VALUE result = rb_protect(ossl_ssl_write_internal_safe, (VALUE)args, &state);
if (!frozen) {
rb_str_unlocktmp(str);
Expand Down
5 changes: 5 additions & 0 deletions test/openssl/test_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ def test_sysread_and_syswrite
ssl.syswrite(str)
assert_same buf, ssl.sysread(str.size, buf)
assert_equal(str, buf)

obj = Object.new
obj.define_singleton_method(:to_str) { str }
ssl.syswrite(obj)
assert_equal(str, ssl.sysread(str.bytesize))
}
}
end
Expand Down
Loading