[Bug #20998] Check if the string is frozen in rb_str_locktmp() & rb_str_unlocktmp()

This commit is contained in:
Benoit Daloze 2025-06-14 13:32:51 +02:00
parent cce4bfdca9
commit 83fb07fb2c
Notes: git 2025-06-16 20:59:22 +00:00
2 changed files with 4 additions and 2 deletions

View file

@ -3664,6 +3664,7 @@ RUBY_ALIAS_FUNCTION(rb_str_dup_frozen(VALUE str), rb_str_new_frozen, (str))
VALUE
rb_str_locktmp(VALUE str)
{
rb_check_frozen(str);
if (FL_TEST(str, STR_TMPLOCK)) {
rb_raise(rb_eRuntimeError, "temporal locking already locked string");
}
@ -3674,6 +3675,7 @@ rb_str_locktmp(VALUE str)
VALUE
rb_str_unlocktmp(VALUE str)
{
rb_check_frozen(str);
if (!FL_TEST(str, STR_TMPLOCK)) {
rb_raise(rb_eRuntimeError, "temporal unlocking already unlocked string");
}