aboutsummaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-10-04 17:59:22 +1100
committerDamien George <damien.p.george@gmail.com>2017-10-04 17:59:22 +1100
commitdfa563c71fead671931e91b786cd649eed517f92 (patch)
tree8cf821b265a73797ceef9c2e6979b9a63712bd04 /py/objstr.c
parenta3dc1b1957d2c96d7c60c2c629c95077b03488a1 (diff)
py/objstr: Make empty bytes object have a null-terminating byte.
Because a lot of string processing functions assume there is a null terminating byte, so they can work in an efficient way. Fixes issue #3334.
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objstr.c b/py/objstr.c
index d17b0a68c..51da7a418 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -1973,8 +1973,8 @@ const mp_obj_type_t mp_type_bytes = {
.locals_dict = (mp_obj_dict_t*)&str8_locals_dict,
};
-// the zero-length bytes
-const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, NULL};
+// The zero-length bytes object, with data that includes a null-terminating byte
+const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, (const byte*)""};
// Create a str/bytes object using the given data. New memory is allocated and
// the data is copied across.