diff --git a/src/module/io.c b/src/module/io.c index ac5a5f6d..785de67f 100644 --- a/src/module/io.c +++ b/src/module/io.c @@ -532,7 +532,15 @@ void stdinIsTerminal(WrenVM* vm) void stdoutFlush(WrenVM* vm) { - fflush(stdout); + wrenEnsureSlots(vm, 1); + + int result = fflush(stdout); + if (result != 0) { + wrenSetSlotString(vm, 0, "Cannot flush Stdout."); + wrenAbortFiber(vm, 0); + return; + } + wrenSetSlotNull(vm, 0); }