diff --git a/src/core/io.c b/src/core/io.c index 474e833a..44904517 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -198,6 +198,9 @@ static Janet cfun_io_fread(int32_t argc, Janet *argv) { if (fsize < 0) { janet_panicf("could not get file size of %v", argv[0]); } + if (fsize > (INT32_MAX)) { + janet_panic("file to large to read into buffer"); + } fseek(iof->file, 0, SEEK_SET); read_chunk(iof, buffer, (int32_t) fsize); } diff --git a/src/core/peg.c b/src/core/peg.c index 23611364..2ab2244f 100644 --- a/src/core/peg.c +++ b/src/core/peg.c @@ -1057,7 +1057,6 @@ static Janet cfun_peg_match(int32_t argc, Janet *argv) { s.captures = janet_array(0); s.scratch = janet_buffer(10); s.tags = janet_buffer(10); - s.constants = peg->constants; s.bytecode = peg->bytecode; const uint8_t *result = peg_rule(&s, s.bytecode, bytes.bytes + start); diff --git a/src/core/vm.c b/src/core/vm.c index ed951706..6777dc83 100644 --- a/src/core/vm.c +++ b/src/core/vm.c @@ -852,7 +852,12 @@ JanetSignal janet_pcall( const Janet *argv, Janet *out, JanetFiber **f) { - JanetFiber *fiber = janet_fiber(fun, 64, argc, argv); + JanetFiber *fiber; + if (f && *f) { + fiber = janet_fiber_reset(*f, fun, argc, argv); + } else { + fiber = janet_fiber(fun, 64, argc, argv); + } if (f) *f = fiber; if (!fiber) { *out = janet_cstringv("arity mismatch");