From 0992588811df90154759f9af6261f07e69cf784a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 1 Jan 2016 07:51:07 +0200 Subject: [PATCH] py/frozenmod: Make frozen module content be 0-terminated. To allow simple zero-terminated lexers. --- py/frozenmod.c | 2 +- tools/make-frozen.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/py/frozenmod.c b/py/frozenmod.c index 84df30b895..440ae0aacf 100644 --- a/py/frozenmod.c +++ b/py/frozenmod.c @@ -46,7 +46,7 @@ mp_lexer_t *mp_find_frozen_module(const char *str, int len) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR_, s, *sz_ptr, 0); return lex; } - s += l + 1 + *sz_ptr++; + s += (l + 1) + (*sz_ptr++ + 1); } return NULL; } diff --git a/tools/make-frozen.py b/tools/make-frozen.py index 18368e218f..7c3865cc41 100755 --- a/tools/make-frozen.py +++ b/tools/make-frozen.py @@ -55,5 +55,5 @@ for f, st in modules: data = data[1:] data = data[1:-1] data = data.replace('"', '\\"') - print('"%s"' % data) + print('"%s\\0"' % data) print("};")