Fix decompressing using qstrs after running the VM

The qstr state still pointed to qstr pools in the released MP heap.
This commit is contained in:
Scott Shawcroft 2023-09-29 14:51:13 -07:00
parent 5126cd3dc3
commit bf3d84195f
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
3 changed files with 10 additions and 1 deletions

4
main.c
View File

@ -219,6 +219,10 @@ STATIC void stop_mp(void) {
usb_background();
#endif
// Set the qstr pool back to the const pools. The heap allocated ones will
// be overwritten.
qstr_reset();
gc_deinit();
}

View File

@ -122,9 +122,13 @@ extern const qstr_pool_t MICROPY_QSTR_EXTRA_POOL;
#define CONST_POOL mp_qstr_const_pool
#endif
void qstr_init(void) {
void qstr_reset(void) {
MP_STATE_VM(last_pool) = (qstr_pool_t *)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left
MP_STATE_VM(qstr_last_chunk) = NULL;
}
void qstr_init(void) {
qstr_reset();
#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
mp_thread_mutex_init(&MP_STATE_VM(qstr_mutex));

View File

@ -78,6 +78,7 @@ typedef struct _qstr_pool_t {
#define QSTR_TOTAL() (MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len)
void qstr_reset(void);
void qstr_init(void);
mp_uint_t qstr_compute_hash(const byte *data, size_t len);