summaryrefslogtreecommitdiffstatshomepage
path: root/py/persistentcode.h
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-09-27 13:43:50 +1000
committerDamien George <damien@micropython.org>2023-10-12 15:17:59 +1100
commit5015779a6f4a180233a78ec8b5fd1ea095057a91 (patch)
treed034986dcc9dde9631838918822cca1ef7f3941a /py/persistentcode.h
parent480659b1ac758c377568c93c0ccda6a232f744ca (diff)
downloadmicropython-5015779a6f4a180233a78ec8b5fd1ea095057a91.tar.gz
micropython-5015779a6f4a180233a78ec8b5fd1ea095057a91.zip
py/builtinevex: Handle invalid filenames for execfile.
If a non-string buffer was passed to execfile, then it would be passed as a non-null-terminated char* to mp_lexer_new_from_file. This changes mp_lexer_new_from_file to take a qstr instead (as in almost all cases a qstr will be created from this input anyway to set the `__file__` attribute on the module). This now makes execfile require a string (not generic buffer) argument, which is probably a good fix to make anyway. Fixes issue #12522. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/persistentcode.h')
-rw-r--r--py/persistentcode.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/persistentcode.h b/py/persistentcode.h
index d363f544ad..140a0e7e80 100644
--- a/py/persistentcode.h
+++ b/py/persistentcode.h
@@ -113,10 +113,10 @@ enum {
void mp_raw_code_load(mp_reader_t *reader, mp_compiled_module_t *ctx);
void mp_raw_code_load_mem(const byte *buf, size_t len, mp_compiled_module_t *ctx);
-void mp_raw_code_load_file(const char *filename, mp_compiled_module_t *ctx);
+void mp_raw_code_load_file(qstr filename, mp_compiled_module_t *ctx);
void mp_raw_code_save(mp_compiled_module_t *cm, mp_print_t *print);
-void mp_raw_code_save_file(mp_compiled_module_t *cm, const char *filename);
+void mp_raw_code_save_file(mp_compiled_module_t *cm, qstr filename);
void mp_native_relocate(void *reloc, uint8_t *text, uintptr_t reloc_text);