* hash.c: fix WB bug.
(1) Hash's key also needs WB. (2) callback parameter *key and *value of st_update() is not a storage of st_table itself (only local variable). So that OBJ_WRITE() is not suitable, especially for `!exsinting'. OBJ_WRITTEN() is used instead of OBJ_WRITE(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1999571e60
commit
68f96f6c3c
@ -1,3 +1,12 @@
|
|||||||
|
Wed May 29 10:33:27 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* hash.c: fix WB bug.
|
||||||
|
(1) Hash's key also needs WB.
|
||||||
|
(2) callback parameter *key and *value of st_update() is not a
|
||||||
|
storage of st_table itself (only local variable). So that
|
||||||
|
OBJ_WRITE() is not suitable, especially for `!exsinting'.
|
||||||
|
OBJ_WRITTEN() is used instead of OBJ_WRITE().
|
||||||
|
|
||||||
Tue May 28 12:31:21 2013 Koichi Sasada <ko1@atdot.net>
|
Tue May 28 12:31:21 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* ext/objspace/object_tracing.c: fix a bug reported at
|
* ext/objspace/object_tracing.c: fix a bug reported at
|
||||||
|
37
hash.c
37
hash.c
@ -1193,14 +1193,23 @@ rb_hash_clear(VALUE hash)
|
|||||||
static int
|
static int
|
||||||
hash_aset(VALUE hash, st_data_t *key, st_data_t *val, st_data_t arg, int existing)
|
hash_aset(VALUE hash, st_data_t *key, st_data_t *val, st_data_t arg, int existing)
|
||||||
{
|
{
|
||||||
OBJ_WRITE(hash, (VALUE *)val, arg);
|
if (existing) {
|
||||||
|
OBJ_WRITTEN(hash, *val, arg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OBJ_WRITTEN(hash, Qundef, *key);
|
||||||
|
OBJ_WRITTEN(hash, Qundef, arg);
|
||||||
|
}
|
||||||
|
*val = arg;
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
hash_aset_str(VALUE hash, st_data_t *key, st_data_t *val, st_data_t arg, int existing)
|
hash_aset_str(VALUE hash, st_data_t *key, st_data_t *val, st_data_t arg, int existing)
|
||||||
{
|
{
|
||||||
OBJ_WRITE(hash, (VALUE *)key, rb_str_new_frozen((VALUE)*key));
|
if (!existing) {
|
||||||
|
*key = rb_str_new_frozen((VALUE)*key);
|
||||||
|
}
|
||||||
return hash_aset(hash, key, val, arg, existing);
|
return hash_aset(hash, key, val, arg, existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1879,7 +1888,14 @@ rb_hash_invert(VALUE hash)
|
|||||||
static int
|
static int
|
||||||
rb_hash_update_callback(VALUE hash, st_data_t *key, st_data_t *value, st_data_t arg, int existing)
|
rb_hash_update_callback(VALUE hash, st_data_t *key, st_data_t *value, st_data_t arg, int existing)
|
||||||
{
|
{
|
||||||
OBJ_WRITE(hash, (VALUE *)value, (VALUE)arg);
|
if (existing) {
|
||||||
|
OBJ_WRITTEN(hash, *value, arg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OBJ_WRITTEN(hash, Qundef, *key);
|
||||||
|
OBJ_WRITTEN(hash, Qundef, arg);
|
||||||
|
}
|
||||||
|
*value = arg;
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1896,10 +1912,16 @@ static int
|
|||||||
rb_hash_update_block_callback(VALUE hash, st_data_t *key, st_data_t *value, st_data_t arg, int existing)
|
rb_hash_update_block_callback(VALUE hash, st_data_t *key, st_data_t *value, st_data_t arg, int existing)
|
||||||
{
|
{
|
||||||
VALUE newvalue = (VALUE)arg;
|
VALUE newvalue = (VALUE)arg;
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
newvalue = rb_yield_values(3, (VALUE)*key, (VALUE)*value, newvalue);
|
newvalue = rb_yield_values(3, (VALUE)*key, (VALUE)*value, newvalue);
|
||||||
|
OBJ_WRITTEN(hash, *value, newvalue);
|
||||||
}
|
}
|
||||||
OBJ_WRITE(hash, (VALUE *)value, newvalue);
|
else {
|
||||||
|
OBJ_WRITTEN(hash, Qundef, *key);
|
||||||
|
OBJ_WRITTEN(hash, Qundef, newvalue);
|
||||||
|
}
|
||||||
|
*value = newvalue;
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1962,8 +1984,13 @@ rb_hash_update_func_callback(VALUE hash, st_data_t *key, st_data_t *value, st_da
|
|||||||
VALUE newvalue = arg->value;
|
VALUE newvalue = arg->value;
|
||||||
if (existing) {
|
if (existing) {
|
||||||
newvalue = (*arg->func)((VALUE)*key, (VALUE)*value, newvalue);
|
newvalue = (*arg->func)((VALUE)*key, (VALUE)*value, newvalue);
|
||||||
|
OBJ_WRITTEN(hash, *value, newvalue);
|
||||||
}
|
}
|
||||||
OBJ_WRITE(hash, (VALUE *)value, (VALUE)newvalue);
|
else {
|
||||||
|
OBJ_WRITTEN(hash, Qundef, *key);
|
||||||
|
OBJ_WRITTEN(hash, Qundef, newvalue);
|
||||||
|
}
|
||||||
|
*value = newvalue;
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user