summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-05 23:58:35 +0800
committerruki <[email protected]>2019-07-05 22:11:19 +0800
commit48f852eefe1f781756e86a2b3fb2bab5e16deda9 (patch)
tree867ca7973d127b1de3e7e73e0433137164f7b398 /core/src
parent0ecef11a75faa178269cd643e7c38d7a43c4d039 (diff)
fix read num and line/free
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/io/file_read.c12
-rw-r--r--core/src/xmake/sandbox/interactive.c3
2 files changed, 5 insertions, 10 deletions
diff --git a/core/src/xmake/io/file_read.c b/core/src/xmake/io/file_read.c
index 6581bff9d..5ae7b91b3 100644
--- a/core/src/xmake/io/file_read.c
+++ b/core/src/xmake/io/file_read.c
@@ -453,15 +453,9 @@ static tb_int_t xm_io_file_std_read_num(lua_State* lua, xm_io_file* file, tb_cha
// read number
tb_char_t strbuf[512];
if (tb_stdfile_gets(file->std_ref, strbuf, tb_arrayn(strbuf)))
- {
- lua_pushnumber(lua, tb_s10tod(strbuf));
- return 1;
- }
- else
- {
- lua_pushnil(lua);
- return 0;
- }
+ lua_pushnumber(lua, tb_s10tod(strbuf)); // TODO check invalid float number string and push nil
+ else lua_pushnil(lua);
+ return 1;
}
/*
diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c
index 75f36d947..95d01a19c 100644
--- a/core/src/xmake/sandbox/interactive.c
+++ b/core/src/xmake/sandbox/interactive.c
@@ -40,6 +40,7 @@
#ifdef XM_CONFIG_API_HAVE_READLINE
# include <readline/history.h>
# include <readline/readline.h>
+# include <stdlib.h>
# include <stdio.h> // on some OS (like centos) required
#endif
@@ -160,7 +161,7 @@ static tb_size_t xm_sandbox_readline(tb_char_t* data, tb_size_t maxn, tb_char_t
tb_size_t size = tb_strlcpy(data, line, maxn);
// free line
- tb_free(line);
+ free((void*)line);
// truncated?
if (size >= maxn) return 0;