summaryrefslogtreecommitdiffstatshomepage
path: root/py/lexerunix.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-09 16:54:03 +0100
committerDamien George <damien.p.george@gmail.com>2014-10-09 16:54:03 +0100
commitf0f964807eaf550e3107b22d51d8fdc905c77ffd (patch)
tree2791cbe24eb236443216962ef7b3456dc7eeb892 /py/lexerunix.c
parent7989b076376900ee6fb0ab7a86875844b5c179aa (diff)
parent9bf5f2857d2015e3d440feb03c102ed9730c8f4d (diff)
downloadmicropython-f0f964807eaf550e3107b22d51d8fdc905c77ffd.tar.gz
micropython-f0f964807eaf550e3107b22d51d8fdc905c77ffd.zip
Merge branch 'dhylands-lexer-crash'
Diffstat (limited to 'py/lexerunix.c')
-rw-r--r--py/lexerunix.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/py/lexerunix.c b/py/lexerunix.c
index 9d669f2bfe..52eac9eda5 100644
--- a/py/lexerunix.c
+++ b/py/lexerunix.c
@@ -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);