From 1f1eeaf358c1529c06fb731d05f92fce0ed12a94 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Wed, 3 Jul 2019 23:54:08 +0200 Subject: [PATCH] fix unref default file descriptor while still in use --- components/modules/file.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/modules/file.c b/components/modules/file.c index d60d81ed..e6d9a7a0 100644 --- a/components/modules/file.c +++ b/components/modules/file.c @@ -123,15 +123,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; }