py: Add further checks for failed malloc in lexer init functions.

This commit is contained in:
Damien George
2014-10-09 16:53:37 +01:00
parent a8202762f0
commit 9bf5f2857d
5 changed files with 11 additions and 4 deletions

View File

@@ -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);