From c789da67a3130c1ba0c235b393a02c96ee22e6a3 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 25 Apr 2021 15:36:21 -0400 Subject: [PATCH 1/2] (chore) stdoutFlush abort if error --- src/module/io.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/module/io.c b/src/module/io.c index ac5a5f6d..98a81d50 100644 --- a/src/module/io.c +++ b/src/module/io.c @@ -532,7 +532,13 @@ void stdinIsTerminal(WrenVM* vm) void stdoutFlush(WrenVM* vm) { - fflush(stdout); + int result = fflush(stdout); + if (result != 0) { + wrenSetSlotString(vm, 0, "Cannot flush Stdout."); + wrenAbortFiber(vm, 0); + return; + } + wrenSetSlotNull(vm, 0); } From f208ef5ca552f64a17fbe9a43fe226d4fe642203 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Wed, 28 Apr 2021 14:06:57 -0400 Subject: [PATCH 2/2] we need a slot --- src/module/io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/module/io.c b/src/module/io.c index 98a81d50..785de67f 100644 --- a/src/module/io.c +++ b/src/module/io.c @@ -532,13 +532,15 @@ void stdinIsTerminal(WrenVM* vm) void stdoutFlush(WrenVM* vm) { + wrenEnsureSlots(vm, 1); + int result = fflush(stdout); if (result != 0) { wrenSetSlotString(vm, 0, "Cannot flush Stdout."); wrenAbortFiber(vm, 0); return; } - + wrenSetSlotNull(vm, 0); }