Skip to content

Commit

Permalink
fix unref default file descriptor while still in use (#2818)
Browse files Browse the repository at this point in the history
  • Loading branch information
devsaurus authored and marcelstoer committed Jul 5, 2019
1 parent 7de8a01 commit bc7ffb3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/modules/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,16 @@ static int file_close( lua_State* L )
ud = (file_fd_ud *)luaL_checkudata(L, 1, "file.obj");
}

// unref default file descriptor
luaL_unref( L, LUA_REGISTRYINDEX, file_fd_ref );
file_fd_ref = LUA_NOREF;

if(ud->fd){
vfs_close(ud->fd);
// mark as closed
ud->fd = 0;
}

// unref default file descriptor
luaL_unref( L, LUA_REGISTRYINDEX, file_fd_ref );
file_fd_ref = LUA_NOREF;

return 0;
}

Expand Down

0 comments on commit bc7ffb3

Please sign in to comment.