summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorLéa Saviot <lea.saviot@numworks.com>2019-11-22 14:06:49 +0100
committerDamien George <damien.p.george@gmail.com>2019-11-26 00:28:32 +1100
commita7bc4d1a1455a8a5cdea53d7a2caf03c9320f460 (patch)
tree9aba81df900652ea42284c9cf800599fff7acaa2 /py
parent6b3404f25e3d901d9b1313f2827a760093cddd92 (diff)
py/builtinimport: Raise exception on empty module name.
To prevent a crash returning MP_OBJ_NULL. A test is added for this case.
Diffstat (limited to 'py')
-rw-r--r--py/builtinimport.c4
1 files changed, 4 insertions, 0 deletions
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);