aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-30 02:37:59 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-30 02:37:59 +0000
commit8ed50fdefa8b38a2371717308a3381e4ebaca8d1 (patch)
treeb9b68f7125279c4c76d895ee8b86f9bdde197f60 /variable.c
parentafc5764181e5fb8ec52ae3e1f6e9d43b3e9ba87f (diff)
downloadruby-8ed50fdefa8b38a2371717308a3381e4ebaca8d1.tar.gz
variable.c (generic_ivar_remove): return original value
This fixes a bug introduced in r50678 ("variable.c: use indices for generic ivars") and does not affect any released version of Ruby * variable.c (generic_ivar_remove): adjust type, set valp (rb_obj_remove_instance_variable): simplify call * test/ruby/test_object.rb (test_remove_instance_variable): expand for implementation details git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/variable.c b/variable.c
index 42a628e086..5bb6722f79 100644
--- a/variable.c
+++ b/variable.c
@@ -1142,7 +1142,7 @@ generic_ivar_defined(VALUE obj, ID id)
}
static int
-generic_ivar_remove(VALUE obj, ID id, st_data_t *valp)
+generic_ivar_remove(VALUE obj, ID id, VALUE *valp)
{
struct gen_ivtbl *ivtbl;
st_data_t key = (st_data_t)id;
@@ -1155,6 +1155,7 @@ generic_ivar_remove(VALUE obj, ID id, st_data_t *valp)
if ((long)index < ivtbl->numiv) {
if (ivtbl->ivptr[index] != Qundef) {
+ *valp = ivtbl->ivptr[index];
ivtbl->ivptr[index] = Qundef;
return 1;
}
@@ -1769,9 +1770,8 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name)
break;
default:
if (FL_TEST(obj, FL_EXIVAR)) {
- v = val;
- if (generic_ivar_remove(obj, (st_data_t)id, &v)) {
- return (VALUE)v;
+ if (generic_ivar_remove(obj, id, &val)) {
+ return val;
}
}
break;