Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
e9f16d1a
Commit
e9f16d1a
authored
Jan 10, 2016
by
Terry Ellison
Browse files
Merge pull request #916 from jmattsson/tmr-limit-check
Range check the tmr interval value.
parents
dcbdfc8e
3fb0de85
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/tmr.c
View file @
e9f16d1a
...
...
@@ -140,10 +140,11 @@ static int tmr_register(lua_State* L){
sint32_t
interval
=
luaL_checkinteger
(
L
,
2
);
uint8_t
mode
=
luaL_checkinteger
(
L
,
3
);
//validate arguments
uint8_t
args_valid
=
interval
<=
0
const
int32_t
MAX_TIMEOUT
=
0xC49BA5
;
// assuming system_timer_reinit() has *not* been called
uint8_t
args_invalid
=
(
interval
<=
0
||
interval
>
MAX_TIMEOUT
)
||
(
mode
!=
TIMER_MODE_SINGLE
&&
mode
!=
TIMER_MODE_SEMI
&&
mode
!=
TIMER_MODE_AUTO
)
||
(
lua_type
(
L
,
4
)
!=
LUA_TFUNCTION
&&
lua_type
(
L
,
4
)
!=
LUA_TLIGHTFUNCTION
);
if
(
args_valid
)
if
(
args_
in
valid
)
return
luaL_error
(
L
,
"wrong arg range"
);
//get the lua function reference
lua_pushvalue
(
L
,
4
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment