From 0ecef11a75faa178269cd643e7c38d7a43c4d039 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 5 Jul 2019 23:56:09 +0800 Subject: fix memory leak --- core/src/xmake/io/open.c | 2 ++ core/src/xmake/io/std.c | 2 ++ 2 files changed, 4 insertions(+) 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); } -- cgit v1.3.1