Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
9bf5f285
Commit
9bf5f285
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Add further checks for failed malloc in lexer init functions.
parent
a8202762
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
py/lexer.c
+1
-1
1 addition, 1 deletion
py/lexer.c
py/lexerstr.c
+1
-1
1 addition, 1 deletion
py/lexerstr.c
py/lexerunix.c
+4
-1
4 additions, 1 deletion
py/lexerunix.c
py/misc.h
+1
-0
1 addition, 0 deletions
py/misc.h
stmhal/lexerfatfs.c
+4
-1
4 additions, 1 deletion
stmhal/lexerfatfs.c
with
11 additions
and
4 deletions
py/lexer.c
+
1
−
1
View file @
9bf5f285
...
...
@@ -731,7 +731,7 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
}
mp_lexer_t
*
mp_lexer_new
(
qstr
src_name
,
void
*
stream_data
,
mp_lexer_stream_next_byte_t
stream_next_byte
,
mp_lexer_stream_close_t
stream_close
)
{
mp_lexer_t
*
lex
=
m_new_maybe
(
mp_lexer_t
,
1
);
mp_lexer_t
*
lex
=
m_new_
obj_
maybe
(
mp_lexer_t
);
// check for memory allocation error
if
(
lex
==
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
py/lexerstr.c
+
1
−
1
View file @
9bf5f285
...
...
@@ -52,7 +52,7 @@ STATIC void str_buf_free(mp_lexer_str_buf_t *sb) {
}
mp_lexer_t
*
mp_lexer_new_from_str_len
(
qstr
src_name
,
const
char
*
str
,
mp_uint_t
len
,
mp_uint_t
free_len
)
{
mp_lexer_str_buf_t
*
sb
=
m_new_maybe
(
mp_lexer_str_buf_t
,
1
);
mp_lexer_str_buf_t
*
sb
=
m_new_
obj_
maybe
(
mp_lexer_str_buf_t
);
if
(
sb
==
NULL
)
{
return
NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
py/lexerunix.c
+
4
−
1
View file @
9bf5f285
...
...
@@ -69,7 +69,10 @@ STATIC void file_buf_close(mp_lexer_file_buf_t *fb) {
}
mp_lexer_t
*
mp_lexer_new_from_file
(
const
char
*
filename
)
{
mp_lexer_file_buf_t
*
fb
=
m_new_obj
(
mp_lexer_file_buf_t
);
mp_lexer_file_buf_t
*
fb
=
m_new_obj_maybe
(
mp_lexer_file_buf_t
);
if
(
fb
==
NULL
)
{
return
NULL
;
}
fb
->
fd
=
open
(
filename
,
O_RDONLY
);
if
(
fb
->
fd
<
0
)
{
m_del_obj
(
mp_lexer_file_buf_t
,
fb
);
...
...
This diff is collapsed.
Click to expand it.
py/misc.h
+
1
−
0
View file @
9bf5f285
...
...
@@ -54,6 +54,7 @@ typedef unsigned int uint;
#define m_new_maybe(type, num) ((type*)(m_malloc_maybe(sizeof(type) * (num))))
#define m_new0(type, num) ((type*)(m_malloc0(sizeof(type) * (num))))
#define m_new_obj(type) (m_new(type, 1))
#define m_new_obj_maybe(type) (m_new_maybe(type, 1))
#define m_new_obj_var(obj_type, var_type, var_num) ((obj_type*)m_malloc(sizeof(obj_type) + sizeof(var_type) * (var_num)))
#define m_new_obj_var_maybe(obj_type, var_type, var_num) ((obj_type*)m_malloc_maybe(sizeof(obj_type) + sizeof(var_type) * (var_num)))
#if MICROPY_ENABLE_FINALISER
...
...
This diff is collapsed.
Click to expand it.
stmhal/lexerfatfs.c
+
4
−
1
View file @
9bf5f285
...
...
@@ -64,7 +64,10 @@ STATIC void file_buf_close(mp_lexer_file_buf_t *fb) {
}
mp_lexer_t
*
mp_lexer_new_from_file
(
const
char
*
filename
)
{
mp_lexer_file_buf_t
*
fb
=
m_new_obj
(
mp_lexer_file_buf_t
);
mp_lexer_file_buf_t
*
fb
=
m_new_obj_maybe
(
mp_lexer_file_buf_t
);
if
(
fb
==
NULL
)
{
return
NULL
;
}
FRESULT
res
=
f_open
(
&
fb
->
fp
,
filename
,
FA_READ
);
if
(
res
!=
FR_OK
)
{
m_del_obj
(
mp_lexer_file_buf_t
,
fb
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment