summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2023-04-13 23:12:43 +0800
committerruki <[email protected]>2023-04-13 23:12:43 +0800
commit2d5cabdbfe1340aefb6c805d1bc09745e2b31bf0 (patch)
treeae7c080d63c88340a7c3840c62d60d10d823c65c /core/src
parentcefc4921fb508082e0923ff9425cbfa932a70100 (diff)
suppress warning
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/tty/term_mode.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/src/xmake/tty/term_mode.c b/core/src/xmake/tty/term_mode.c
index 975c8fc37..174fdb8db 100644
--- a/core/src/xmake/tty/term_mode.c
+++ b/core/src/xmake/tty/term_mode.c
@@ -52,7 +52,7 @@ tb_int_t xm_tty_term_mode(lua_State* lua)
// get and set terminal mode
DWORD mode = 0;
- HANDLE console_handle;
+ HANDLE console_handle = INVALID_HANDLE_VALUE;
switch (stdtype)
{
case 1: console_handle = GetStdHandle(STD_INPUT_HANDLE); break;
@@ -63,7 +63,8 @@ tb_int_t xm_tty_term_mode(lua_State* lua)
if (lua_isnumber(lua, 2))
{
tb_int_t newmode = (tb_int_t)lua_tointeger(lua, 2);
- SetConsoleMode(console_handle, (DWORD)newmode);
+ if (console_handle != INVALID_HANDLE_VALUE)
+ SetConsoleMode(console_handle, (DWORD)newmode);
}
#else
tb_int_t mode = 0;