summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-31 08:19:35 +0800
committerruki <[email protected]>2017-05-31 08:20:10 +0800
commitf4c6af603c6b8deb2821600d02409a670748efcc (patch)
treecf061d5ca08f82918904e914f4d42c783e37e01b
parentf01d5364141a3e2a965bd9d46e65a2bd851e27ec (diff)
fix winreg.query malloc
-rw-r--r--core/src/xmake/winreg/query.c4
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua4
2 files changed, 4 insertions, 4 deletions
diff --git a/core/src/xmake/winreg/query.c b/core/src/xmake/winreg/query.c
index 036d4a7c3..4d2732ae6 100644
--- a/core/src/xmake/winreg/query.c
+++ b/core/src/xmake/winreg/query.c
@@ -151,7 +151,7 @@ tb_int_t xm_winreg_query(lua_State* lua)
}
// make value buffer
- value = (tb_char_t*)tb_malloc0(valuesize);
+ value = (tb_char_t*)tb_malloc0(valuesize + 1);
tb_assert_and_check_break(value);
// get value result
@@ -183,7 +183,7 @@ tb_int_t xm_winreg_query(lua_State* lua)
}
// make value buffer
- value = (tb_char_t*)tb_malloc0(valuesize);
+ value = (tb_char_t*)tb_malloc0(valuesize + 1);
tb_assert_and_check_break(value);
// get value result
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index 7ee0fb5a9..81fdc285b 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -80,11 +80,11 @@ function sandbox_lib_detect_find_program._find(name, pathes, check)
-- get registry value
local value, errors = winreg.query(regpath)
if not value then
- raise(errors)
+ utils.verror(errors)
end
-- file path not exists? attempt to parse path from `"path" xxx`
- if not os.exists(value) then
+ if value and not os.exists(value) then
value = value:match("\"(.-)\"")
end