summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
diff options
context:
space:
mode:
authordearblue <[email protected]>2020-10-22 22:55:35 +0900
committerdearblue <[email protected]>2020-10-22 22:55:35 +0900
commitf0a64329b1cb8156e0d525d003e5d6ff03b7832f (patch)
tree0f7cfdcfb3af7fb51fcc9e4c60aba736ca10d5d1 /src/array.c
parent27492e53a0440aee7c411d5e72b6f092cf85d6a1 (diff)
downloadmruby-f0a64329b1cb8156e0d525d003e5d6ff03b7832f.tar.gz
mruby-f0a64329b1cb8156e0d525d003e5d6ff03b7832f.zip
Prohibit array changes by "a"/"*" specifier of `mrb_get_args()`
The "a"/"*" specifier of the `mrb_get_args()` function will now return `const mrb_value *`. This is because it is difficult for the caller to check if it is an array object and write-barrier if necessary. And it requires calling `mrb_ary_modify()` on the unmodified array object, which is also difficult (this is similar to #5087).
Diffstat (limited to 'src/array.c')
-rw-r--r--src/array.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/array.c b/src/array.c
index c4bc554ef..71e5d0a1f 100644
--- a/src/array.c
+++ b/src/array.c
@@ -280,7 +280,7 @@ static mrb_value
mrb_ary_s_create(mrb_state *mrb, mrb_value klass)
{
mrb_value ary;
- mrb_value *vals;
+ const mrb_value *vals;
mrb_int len;
struct RArray *a;
@@ -340,7 +340,7 @@ mrb_ary_plus(mrb_state *mrb, mrb_value self)
{
struct RArray *a1 = mrb_ary_ptr(self);
struct RArray *a2;
- mrb_value *ptr;
+ const mrb_value *ptr;
mrb_int blen, len1;
mrb_get_args(mrb, "a", &ptr, &blen);
@@ -615,7 +615,8 @@ static mrb_value
mrb_ary_unshift_m(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
- mrb_value *vals, *ptr;
+ const mrb_value *vals;
+ mrb_value *ptr;
mrb_int alen, len;
mrb_get_args(mrb, "*!", &vals, &alen);
@@ -832,7 +833,7 @@ aget_index(mrb_state *mrb, mrb_value index)
#endif
else {
mrb_int i, argc;
- mrb_value *argv;
+ const mrb_value *argv;
mrb_get_args(mrb, "i*!", &i, &argv, &argc);
return i;