Skip to content

Commit 086a1fc

Browse files
committed
fix null in .mpy
1 parent 8222e71 commit 086a1fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

py/persistentcode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ STATIC mp_obj_t load_obj(mp_reader_t *reader) {
228228
vstr_t vstr;
229229
vstr_init_len(&vstr, len);
230230
read_bytes(reader, (byte *)vstr.buf, len);
231-
read_byte(reader); // skip null terminator
232231
if (obj_type == 's' || obj_type == 'b') {
232+
read_byte(reader); // skip null terminator
233233
return mp_obj_new_str_from_vstr(obj_type == 's' ? &mp_type_str : &mp_type_bytes, &vstr);
234234
} else if (obj_type == 'i') {
235235
return mp_parse_num_integer(vstr.buf, vstr.len, 10, NULL);
@@ -532,7 +532,7 @@ STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
532532
const char *str = mp_obj_str_get_data(o, &len);
533533
mp_print_bytes(print, &obj_type, 1);
534534
mp_print_uint(print, len);
535-
mp_print_bytes(print, (const byte *)str, len + 1);
535+
mp_print_bytes(print, (const byte *)str, len + 1); // +1 to store null terminator
536536
} else if (MP_OBJ_TO_PTR(o) == &mp_const_ellipsis_obj) {
537537
byte obj_type = 'e';
538538
mp_print_bytes(print, &obj_type, 1);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy