mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 09:33:59 +02:00
merge revision(s) ed6fbb79e1
: [Backport #19339]
Fix crash when defining ivars on special constants [Bug #19339] --- test/ruby/test_variable.rb | 6 ++++++ vm_insnhelper.c | 5 +++++ 2 files changed, 11 insertions(+)
This commit is contained in:
parent
373e62248c
commit
c0df0a85de
3 changed files with 12 additions and 1 deletions
|
@ -261,6 +261,12 @@ class TestVariable < Test::Unit::TestCase
|
|||
v.instance_variable_set(:@foo, :bar)
|
||||
end
|
||||
|
||||
assert_raise_with_message(FrozenError, msg, "[Bug #19339]") do
|
||||
v.instance_eval do
|
||||
@a = 1
|
||||
end
|
||||
end
|
||||
|
||||
assert_nil EnvUtil.suppress_warning {v.instance_variable_get(:@foo)}
|
||||
assert_not_send([v, :instance_variable_defined?, :@foo])
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 16
|
||||
#define RUBY_PATCHLEVEL 17
|
||||
|
||||
#include "ruby/version.h"
|
||||
#include "ruby/internal/abi.h"
|
||||
|
|
|
@ -1562,6 +1562,11 @@ vm_getinstancevariable(const rb_iseq_t *iseq, VALUE obj, ID id, IVC ic)
|
|||
static inline void
|
||||
vm_setinstancevariable(const rb_iseq_t *iseq, VALUE obj, ID id, VALUE val, IVC ic)
|
||||
{
|
||||
if (RB_SPECIAL_CONST_P(obj)) {
|
||||
rb_error_frozen_object(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
shape_id_t dest_shape_id;
|
||||
attr_index_t index;
|
||||
vm_ic_atomic_shape_and_index(ic, &dest_shape_id, &index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue