fix unref default file descriptor while still in use (#2818)

This commit is contained in:
Arnim Läuger 2019-07-05 07:55:54 +02:00 committed by Marcel Stör
parent 7de8a01705
commit bc7ffb3eb8
1 changed files with 5 additions and 4 deletions

View File

@ -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;
}