Skip to content

Commit bc7ffb3

Browse files
devsaurusmarcelstoer
authored andcommitted
fix unref default file descriptor while still in use (#2818)
1 parent 7de8a01 commit bc7ffb3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

app/modules/file.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,16 @@ static int file_close( lua_State* L )
126126
ud = (file_fd_ud *)luaL_checkudata(L, 1, "file.obj");
127127
}
128128

129-
// unref default file descriptor
130-
luaL_unref( L, LUA_REGISTRYINDEX, file_fd_ref );
131-
file_fd_ref = LUA_NOREF;
132-
133129
if(ud->fd){
134130
vfs_close(ud->fd);
135131
// mark as closed
136132
ud->fd = 0;
137133
}
134+
135+
// unref default file descriptor
136+
luaL_unref( L, LUA_REGISTRYINDEX, file_fd_ref );
137+
file_fd_ref = LUA_NOREF;
138+
138139
return 0;
139140
}
140141

0 commit comments

Comments
 (0)