Skip to content

Commit

Permalink
save/restore arena index around yield; ref #3359
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 28, 2016
1 parent 6af8cc3 commit 803bf01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mrbgems/mruby-string-ext/src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ mrb_str_lines(mrb_state *mrb, mrb_value self)
mrb_get_args(mrb, "&", &blk);

result = mrb_ary_new(mrb);

ai = mrb_gc_arena_save(mrb);
if (!mrb_nil_p(blk)) {
while (p < e) {
t = p;
Expand All @@ -324,6 +324,7 @@ mrb_str_lines(mrb_state *mrb, mrb_value self)
len = (mrb_int) (p - t);
arg = mrb_str_new(mrb, t, len);
mrb_yield_argv(mrb, blk, 1, &arg);
mrb_gc_arena_restore(mrb, ai);
if (b != RSTRING_PTR(self)) {
ptrdiff_t diff = p - b;
b = RSTRING_PTR(self);
Expand All @@ -334,7 +335,6 @@ mrb_str_lines(mrb_state *mrb, mrb_value self)
return self;
}
while (p < e) {
ai = mrb_gc_arena_save(mrb);
t = p;
while (p < e && *p != '\n') p++;
if (*p == '\n') p++;
Expand Down

0 comments on commit 803bf01

Please sign in to comment.