fix invalid memory access

This commit is contained in:
takase1121 2022-01-22 23:30:48 +08:00
parent 8c8bd4692c
commit f24ebf853d
No known key found for this signature in database
GPG Key ID: 60EEFFC68EB3031B
1 changed files with 1 additions and 1 deletions

View File

@ -306,7 +306,7 @@ static int g_read(lua_State* L, int stream, unsigned long read_size) {
#else
luaL_Buffer b;
luaL_buffinit(L, &b);
uint8_t* buffer = (uint8_t*)luaL_prepbuffer(&b);
uint8_t* buffer = (uint8_t*)luaL_prepbuffsize(&b, READ_BUF_SIZE);
length = read(self->child_pipes[stream][0], buffer, read_size > READ_BUF_SIZE ? READ_BUF_SIZE : read_size);
if (length == 0 && !poll_process(self, WAIT_NONE))
return 0;