Merge pull request #815 from takase1121/fix-subprocess-read

fix invalid memory access
This commit is contained in:
Adam 2022-01-22 11:18:19 -05:00 committed by GitHub
commit 9cb25acd7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;