From a7bc4d1a1455a8a5cdea53d7a2caf03c9320f460 Mon Sep 17 00:00:00 2001 From: Léa Saviot Date: Fri, 22 Nov 2019 14:06:49 +0100 Subject: py/builtinimport: Raise exception on empty module name. To prevent a crash returning MP_OBJ_NULL. A test is added for this case. --- py/builtinimport.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'py') diff --git a/py/builtinimport.c b/py/builtinimport.c index b9f6c2ab2..9d91b2059 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -334,6 +334,10 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { mod_len = new_mod_l; } + if (mod_len == 0) { + mp_raise_ValueError(NULL); + } + // check if module already exists qstr module_name_qstr = mp_obj_str_get_qstr(module_name); mp_obj_t module_obj = mp_module_get(module_name_qstr); -- cgit v1.2.3