Skip to content

Commit 4dc68f3

Browse files
authored
Merge pull request #776 from phanen/fix-assertion
fix: `uv.write(pipe, {})` trigger `assert(nbufs > 0)`
2 parents ed1e812 + a99e959 commit 4dc68f3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/misc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ static void luv_prep_buf(lua_State *L, int idx, uv_buf_t *pbuf) {
5757
static uv_buf_t* luv_prep_bufs(lua_State* L, int index, size_t *count, int **refs) {
5858
uv_buf_t *bufs;
5959
size_t i;
60-
*count = lua_rawlen(L, index);
60+
size_t cnt;
61+
cnt = lua_rawlen(L, index);
62+
if (cnt == 0) {
63+
luaL_argerror(L, index, "expected non-empty table of strings");
64+
return NULL;
65+
}
66+
*count = cnt;
6167
bufs = (uv_buf_t*)malloc(sizeof(uv_buf_t) * *count);
6268
int *refs_array = NULL;
6369
if (refs)

0 commit comments

Comments
 (0)