summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-05 23:56:09 +0800
committerruki <[email protected]>2019-07-05 22:11:19 +0800
commit0ecef11a75faa178269cd643e7c38d7a43c4d039 (patch)
tree84ec820db38cb2e5b6e8b07d8de53c2cd22b9f9c /core/src
parentef2b7d06c8964c33567d44008099770a06ea897d (diff)
fix memory leak
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/io/open.c2
-rw-r--r--core/src/xmake/io/std.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/core/src/xmake/io/open.c b/core/src/xmake/io/open.c
index f6878604b..0ee3d10cb 100644
--- a/core/src/xmake/io/open.c
+++ b/core/src/xmake/io/open.c
@@ -286,6 +286,8 @@ tb_int_t xm_io_open(lua_State* lua)
// new file
xm_io_file* xm_file = xm_io_newfile(lua);
xm_file->file_ref = file_ref;
+ xm_file->stream = stream;
+ xm_file->fstream = fstream;
xm_file->mode = mode;
xm_file->type = XM_IO_FILE_TYPE_FILE;
xm_file->encoding = encoding;
diff --git a/core/src/xmake/io/std.c b/core/src/xmake/io/std.c
index 33b6e0a93..80ded866f 100644
--- a/core/src/xmake/io/std.c
+++ b/core/src/xmake/io/std.c
@@ -111,6 +111,8 @@ static tb_void_t xm_io_std_init(lua_State* lua, tb_size_t type)
file->type = xm_io_std_isatty(type);
file->path = path;
file->std_ref = fp;
+ file->stream = tb_null;
+ file->fstream = tb_null;
tb_char_t const* info = xm_io_file_is_tty(file) ? "" : " redirected";
tb_snprintf(file->name, tb_arrayn(file->name), "file: (%s%s)", name, info);
}