Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
8790924c
Commit
8790924c
authored
Oct 09, 2018
by
Nathaniel Wesley Filardo
Committed by
Marcel Stör
Oct 09, 2018
Browse files
Check os_realloc calls (#2513)
parent
509be837
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/cron.c
View file @
8790924c
...
...
@@ -78,6 +78,7 @@ static int lcron_parsedesc(lua_State *L, char *str, struct cronent_desc *desc) {
static
int
lcron_create
(
lua_State
*
L
)
{
// Check arguments
char
*
strdesc
=
(
char
*
)
luaL_checkstring
(
L
,
1
);
void
*
newlist
;
luaL_checkanyfunction
(
L
,
2
);
// Parse description
struct
cronent_desc
desc
;
...
...
@@ -93,8 +94,12 @@ static int lcron_create(lua_State *L) {
// Set entry
ud
->
desc
=
desc
;
// Store entry
newlist
=
os_realloc
(
cronent_list
,
sizeof
(
int
)
*
(
cronent_count
+
1
));
if
(
newlist
==
NULL
)
{
return
luaL_error
(
L
,
"out of memory"
);
}
lua_pushvalue
(
L
,
-
1
);
cronent_list
=
os_realloc
(
cronent_list
,
sizeof
(
int
)
*
(
cronent_count
+
1
))
;
cronent_list
=
newlist
;
cronent_list
[
cronent_count
++
]
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
return
1
;
}
...
...
@@ -120,8 +125,13 @@ static int lcron_schedule(lua_State *L) {
ud
->
desc
=
desc
;
size_t
i
=
lcron_findindex
(
L
,
ud
);
if
(
i
==
-
1
)
{
void
*
newlist
;
newlist
=
os_realloc
(
cronent_list
,
sizeof
(
int
)
*
(
cronent_count
+
1
));
if
(
newlist
==
NULL
)
{
return
luaL_error
(
L
,
"out of memory"
);
}
cronent_list
=
newlist
;
lua_pushvalue
(
L
,
1
);
cronent_list
=
os_realloc
(
cronent_list
,
sizeof
(
int
)
*
(
cronent_count
+
1
));
cronent_list
[
cronent_count
++
]
=
lua_ref
(
L
,
LUA_REGISTRYINDEX
);
}
return
0
;
...
...
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