mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[Bug #20998] Check if the string is frozen in rb_str_locktmp() & rb_str_unlocktmp()
This commit is contained in:
parent
cce4bfdca9
commit
83fb07fb2c
Notes:
git
2025-06-16 20:59:22 +00:00
2 changed files with 4 additions and 2 deletions
|
@ -1222,7 +1222,7 @@ describe "C-API String function" do
|
||||||
-> { str.upcase! }.should raise_error(RuntimeError, 'can\'t modify string; temporarily locked')
|
-> { str.upcase! }.should raise_error(RuntimeError, 'can\'t modify string; temporarily locked')
|
||||||
end
|
end
|
||||||
|
|
||||||
ruby_bug "#20998", ""..."3.6" do # TODO: check when Ruby 3.5 is released
|
ruby_version_is "3.5" do
|
||||||
it "raises FrozenError if string is frozen" do
|
it "raises FrozenError if string is frozen" do
|
||||||
str = -"rb_str_locktmp"
|
str = -"rb_str_locktmp"
|
||||||
-> { @s.rb_str_locktmp(str) }.should raise_error(FrozenError)
|
-> { @s.rb_str_locktmp(str) }.should raise_error(FrozenError)
|
||||||
|
@ -1246,7 +1246,7 @@ describe "C-API String function" do
|
||||||
-> { @s.rb_str_unlocktmp(+"test") }.should raise_error(RuntimeError, 'temporal unlocking already unlocked string')
|
-> { @s.rb_str_unlocktmp(+"test") }.should raise_error(RuntimeError, 'temporal unlocking already unlocked string')
|
||||||
end
|
end
|
||||||
|
|
||||||
ruby_bug "#20998", ""..."3.6" do # TODO: check when Ruby 3.5 is released
|
ruby_version_is "3.5" do
|
||||||
it "raises FrozenError if string is frozen" do
|
it "raises FrozenError if string is frozen" do
|
||||||
str = -"rb_str_locktmp"
|
str = -"rb_str_locktmp"
|
||||||
-> { @s.rb_str_unlocktmp(str) }.should raise_error(FrozenError)
|
-> { @s.rb_str_unlocktmp(str) }.should raise_error(FrozenError)
|
||||||
|
|
2
string.c
2
string.c
|
@ -3664,6 +3664,7 @@ RUBY_ALIAS_FUNCTION(rb_str_dup_frozen(VALUE str), rb_str_new_frozen, (str))
|
||||||
VALUE
|
VALUE
|
||||||
rb_str_locktmp(VALUE str)
|
rb_str_locktmp(VALUE str)
|
||||||
{
|
{
|
||||||
|
rb_check_frozen(str);
|
||||||
if (FL_TEST(str, STR_TMPLOCK)) {
|
if (FL_TEST(str, STR_TMPLOCK)) {
|
||||||
rb_raise(rb_eRuntimeError, "temporal locking already locked string");
|
rb_raise(rb_eRuntimeError, "temporal locking already locked string");
|
||||||
}
|
}
|
||||||
|
@ -3674,6 +3675,7 @@ rb_str_locktmp(VALUE str)
|
||||||
VALUE
|
VALUE
|
||||||
rb_str_unlocktmp(VALUE str)
|
rb_str_unlocktmp(VALUE str)
|
||||||
{
|
{
|
||||||
|
rb_check_frozen(str);
|
||||||
if (!FL_TEST(str, STR_TMPLOCK)) {
|
if (!FL_TEST(str, STR_TMPLOCK)) {
|
||||||
rb_raise(rb_eRuntimeError, "temporal unlocking already unlocked string");
|
rb_raise(rb_eRuntimeError, "temporal unlocking already unlocked string");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue