summaryrefslogtreecommitdiffstatshomepage
path: root/py/qstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-13 16:21:23 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-13 16:21:23 +0000
commit4c81ba8015238a343593468aa5173440fd392e32 (patch)
tree06da514f28ea3ef4758898f533e29c33a6c250c9 /py/qstr.c
parentdab1385177558f1d27c03b59e443b6fa25a2cdc0 (diff)
downloadmicropython-4c81ba8015238a343593468aa5173440fd392e32.tar.gz
micropython-4c81ba8015238a343593468aa5173440fd392e32.zip
py: Never intern data of large string/bytes object; add relevant tests.
Previously to this patch all constant string/bytes objects were interned by the compiler, and this lead to crashes when the qstr was too long (noticeable now that qstr length storage defaults to 1 byte). With this patch, long string/bytes objects are never interned, and are referenced directly as constant objects within generated code using load_const_obj.
Diffstat (limited to 'py/qstr.c')
-rw-r--r--py/qstr.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/qstr.c b/py/qstr.c
index c244738a5e..2553872b16 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -148,6 +148,7 @@ qstr qstr_from_str(const char *str) {
}
qstr qstr_from_strn(const char *str, mp_uint_t len) {
+ assert(len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN)));
qstr q = qstr_find_strn(str, len);
if (q == 0) {
mp_uint_t hash = qstr_compute_hash((const byte*)str, len);