From a666e0b0e4e25790b28c772ff6fde992b41ac4e3 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 28 Jun 2017 18:33:08 +0200 Subject: [PATCH] le2lib: return error if fflush before fork fails Signed-off-by: Tobias Ulmer --- generic/le2lib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/generic/le2lib.c b/generic/le2lib.c index 1d6e3ae..be4ebc6 100644 --- a/generic/le2lib.c +++ b/generic/le2lib.c @@ -43,10 +43,16 @@ static int lua_fork(lua_State *lua) { int rc; - fflush(0); - rc = fork(); - if(rc < 0) { + rc = fflush(NULL); + if (rc == EOF) { + lua_pushboolean(lua, 0); + lua_pushstring(lua, strerror(errno)); + return 2; + } + + rc = fork(); + if (rc < 0) { lua_pushboolean(lua, 0); lua_pushstring(lua, strerror(errno)); return 2; -- 2.39.5