diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-04 07:27:10 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-04 07:27:10 +0000 |
commit | 3553a86eb51365cc524cf5c549b37770448d550d (patch) | |
tree | 9a96e1d3ccc6de7a94b8d884ddb946b3c3701de3 /ext/dbm/dbm.c | |
parent | 52912db4a81f9b9b69ab9e9fcd95e22d086d4289 (diff) | |
download | ruby-3553a86eb51365cc524cf5c549b37770448d550d.tar.gz |
ext: use RARRAY_CONST_PTR
* ext/bigdecimal/bigdecimal.c: use RARRAY_CONST_PTR just fore
reference instead of RARRAY_PTR, to keep the array WB-protected.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm/dbm.c')
-rw-r--r-- | ext/dbm/dbm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index d2904f5bbe..9202b9c2a8 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -528,7 +528,7 @@ fdbm_delete_if(VALUE obj) } for (i = 0; i < RARRAY_LEN(ary); i++) { - keystr = RARRAY_PTR(ary)[i]; + keystr = RARRAY_CONST_PTR(ary)[i]; key.dptr = RSTRING_PTR(keystr); key.dsize = (DSIZE_TYPE)RSTRING_LEN(keystr); if (dbm_delete(dbm, key)) { @@ -599,11 +599,13 @@ static VALUE fdbm_store(VALUE,VALUE,VALUE); static VALUE update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm)) { + const VALUE *ptr; Check_Type(pair, T_ARRAY); if (RARRAY_LEN(pair) < 2) { rb_raise(rb_eArgError, "pair must be [key, value]"); } - fdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]); + ptr = RARRAY_CONST_PTR(pair); + fdbm_store(dbm, ptr[0], ptr[1]); return Qnil; } |