Skip to content
Snippets Groups Projects
Commit e20cbbec authored by Dave Hylands's avatar Dave Hylands
Browse files

Make lexer fail gracefully when memory can't be allocated.

parent 67f25dfe
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,10 @@ STATIC void str_buf_free(mp_lexer_str_buf_t *sb) { ...@@ -52,7 +52,10 @@ 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_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_obj(mp_lexer_str_buf_t); mp_lexer_str_buf_t *sb = m_new_maybe(mp_lexer_str_buf_t, 1);
if (sb == NULL) {
return NULL;
}
sb->free_len = free_len; sb->free_len = free_len;
sb->src_beg = str; sb->src_beg = str;
sb->src_cur = str; sb->src_cur = str;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment