Skip to content

Commit

Permalink
Add ary_modify() checks; close #3379
Browse files Browse the repository at this point in the history
This issue was reported by https://hackerone.com/an0n-j
  • Loading branch information
matz committed Jan 7, 2017
1 parent 8c11b04 commit 392d7fb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ mrb_ary_pop(mrb_state *mrb, mrb_value ary)
{
struct RArray *a = mrb_ary_ptr(ary);

ary_modify(mrb, a);
if (a->len == 0) return mrb_nil_value();
return a->ptr[--a->len];
}
Expand All @@ -452,6 +453,7 @@ mrb_ary_shift(mrb_state *mrb, mrb_value self)
struct RArray *a = mrb_ary_ptr(self);
mrb_value val;

ary_modify(mrb, a);
if (a->len == 0) return mrb_nil_value();
if (ARY_SHARED_P(a)) {
L_SHIFT:
Expand Down Expand Up @@ -964,6 +966,7 @@ mrb_ary_clear(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);

ary_modify(mrb, a);
if (ARY_SHARED_P(a)) {
mrb_ary_decref(mrb, a->aux.shared);
ARY_UNSET_SHARED_FLAG(a);
Expand Down

0 comments on commit 392d7fb

Please sign in to comment.