aboutsummaryrefslogtreecommitdiff
path: root/stmhal
diff options
context:
space:
mode:
authorDamien George2014-10-09 16:53:37 +0100
committerDamien George2014-10-09 16:53:37 +0100
commit9bf5f2857d2015e3d440feb03c102ed9730c8f4d (patch)
tree2791cbe24eb236443216962ef7b3456dc7eeb892 /stmhal
parenta8202762f0092896c45378cea95076780b2c0aae (diff)
py: Add further checks for failed malloc in lexer init functions.
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/lexerfatfs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/stmhal/lexerfatfs.c b/stmhal/lexerfatfs.c
index 21e3a2007..ea47aaf88 100644
--- a/stmhal/lexerfatfs.c
+++ b/stmhal/lexerfatfs.c
@@ -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);