Skip to content

Commit

Permalink
fix segfault in luv_check_handle/luv_check_stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal2453 committed Mar 3, 2023
1 parent 353d313 commit 9e205e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ static uv_handle_t* luv_check_handle(lua_State* L, int index) {
isHandle = lua_toboolean(L, -1);
lua_pop(L, 2);
if (!isHandle) goto fail;
// cast the uesrdata to uv_handle_t
// cast the userdata to uv_handle_t
handle = *(uv_handle_t**)udata;
if (!handle || !handle->data) goto fail;
if (!handle->data) goto fail;
return handle;

fail: luaL_argerror(L, index, "Expected uv_handle userdata");
Expand Down
2 changes: 1 addition & 1 deletion src/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static uv_stream_t* luv_check_stream(lua_State* L, int index) {
if (!isStream) goto fail;
// cast the userdata to uv_stream_t
handle = *(uv_stream_t**)udata;
if (!handle || !handle->data) goto fail;
if (!handle->data) goto fail;
return handle;

fail: luaL_argerror(L, index, "Expected uv_stream userdata");
Expand Down

0 comments on commit 9e205e1

Please sign in to comment.