From d4673f065aaf7599c06a5e034fb9b555c88a4170 Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Thu, 8 Jul 2021 15:23:41 +0800 Subject: [PATCH] remove default read buffer size This prevents newcomers from doing process:read(BUF_SIZE) and cause the whole process to hang because process:read() accepts a stream parameter --- src/api/process.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/api/process.c b/src/api/process.c index 95d5ff63..ea43b52e 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -10,8 +10,6 @@ #include #include "api.h" -#define READ_BUF_SIZE 4096 - #define L_GETTABLE(L, idx, key, conv, def) ( \ lua_getfield(L, idx, key), \ conv(L, -1, def) \ @@ -230,7 +228,7 @@ static int f_returncode(lua_State *L) static int g_read(lua_State* L, int stream) { process_t* self = (process_t*) lua_touserdata(L, 1); - unsigned long read_size = luaL_optunsigned(L, 2, READ_BUF_SIZE); + unsigned long read_size = luaL_checkunsigned(L, 2); luaL_Buffer b; uint8_t* buffer = (uint8_t*) luaL_buffinitsize(L, &b, read_size);