Permalink
Browse files

save/restore arena index around yield; ref #3359

  • Loading branch information...
matz committed Dec 24, 2016
1 parent 6af8cc3 commit 803bf010ca9a963abfab2ec348ae1c5c98f41bc2
Showing with 2 additions and 2 deletions.
  1. +2 −2 mrbgems/mruby-string-ext/src/string.c
@@ -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;
@@ -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);
@@ -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++;

0 comments on commit 803bf01

Please sign in to comment.