summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/py/runtime.c b/py/runtime.c
index a5a5bc5a4a..7a701fec57 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include <alloca.h>
#include "mpconfig.h"
#include "nlr.h"
@@ -1074,11 +1075,12 @@ import_error:
uint pkg_name_len;
const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len);
- char dot_name[pkg_name_len + 1 + qstr_len(name)];
+ const uint dot_name_len = pkg_name_len + 1 + qstr_len(name);
+ char *dot_name = alloca(dot_name_len);
memcpy(dot_name, pkg_name, pkg_name_len);
dot_name[pkg_name_len] = '.';
memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name));
- qstr dot_name_q = qstr_from_strn(dot_name, sizeof(dot_name));
+ qstr dot_name_q = qstr_from_strn(dot_name, dot_name_len);
mp_obj_t args[5];
args[0] = MP_OBJ_NEW_QSTR(dot_name_q);