summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-01-24 16:57:46 -0500
committerDan Halbert <halbert@halwitz.org>2018-01-24 19:24:36 -0500
commit302ad40fb28e96809b42c3387b6422994e032b21 (patch)
treec68af5f3e68352b49159e3d403bdb2fd0ce6d760 /py/runtime.c
parent5de29acbd2764e334d010ec3d476c779fde7142d (diff)
Revert "alloca seems buggy on M4"
This reverts commit 4b1e9d8f92aa948f8ecccf364edcb911a135f2c8.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 7a16e4a1b..cbec82f17 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -1428,10 +1428,9 @@ import_error:
mp_load_method_maybe(module, MP_QSTR___name__, dest);
size_t pkg_name_len;
const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len);
+
const uint dot_name_len = pkg_name_len + 1 + qstr_len(name);
- // Previously dot_name was created using alloca(), but that caused run-time crashes on M4 due to
- // stack corruption (compiler bug, it appears), so use an array instead.
- char dot_name[dot_name_len];
+ 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));