mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
io.c: check null char
* io.c (ruby_set_inplace_mode): check if null is contained. based on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272]. [Bug #13960] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
85847e78a0
commit
8148b7013c
2 changed files with 8 additions and 2 deletions
4
io.c
4
io.c
|
@ -12224,10 +12224,10 @@ argf_inplace_mode_set(VALUE argf, VALUE val)
|
|||
ARGF.inplace = 0;
|
||||
}
|
||||
else {
|
||||
StringValue(val);
|
||||
const char *suffix = StringValueCStr(val);
|
||||
if (ARGF.inplace) free(ARGF.inplace);
|
||||
ARGF.inplace = 0;
|
||||
ARGF.inplace = strdup(RSTRING_PTR(val));
|
||||
ARGF.inplace = strdup(suffix);
|
||||
}
|
||||
return argf;
|
||||
}
|
||||
|
|
|
@ -310,6 +310,12 @@ class TestArgf < Test::Unit::TestCase
|
|||
};
|
||||
end
|
||||
|
||||
def test_inplace_invalid_backup
|
||||
assert_raise(ArgumentError, '[ruby-dev:50272] [Bug #13960]') {
|
||||
ARGF.inplace_mode = "a\0"
|
||||
}
|
||||
end
|
||||
|
||||
def test_encoding
|
||||
ruby('-e', "#{<<~"{#"}\n#{<<~'};'}", @t1.path, @t2.path, @t3.path) do |f|
|
||||
{#
|
||||
|
|
Loading…
Reference in a new issue