fix(jpeg): Fix memory leak on jpeg decoder

This commit is contained in:
Cao Sen Miao 2024-03-12 14:45:55 +08:00
parent 4ee54026e3
commit 4881a2aca0
3 changed files with 7 additions and 2 deletions

View File

@ -169,7 +169,9 @@ esp_err_t jpeg_isr_deregister(jpeg_codec_handle_t jpeg_codec, jpeg_isr_handler_t
break;
}
prev = it;
free(prev);
}
if (found) {
free(it);
}
if (unlikely(found != true)) {
return ESP_ERR_INVALID_STATE;

View File

@ -263,6 +263,9 @@ esp_err_t jpeg_del_decoder_engine(jpeg_decoder_handle_t decoder_engine)
if (decoder_engine->header_info) {
free(decoder_engine->header_info);
}
if (decoder_engine->trans_desc) {
free(decoder_engine->trans_desc);
}
if (decoder_engine->evt_queue) {
vQueueDeleteWithCaps(decoder_engine->evt_queue);
}

View File

@ -30,7 +30,7 @@ TEST_CASE("JPEG decode driver memory leaking check", "[jpeg]")
};
int size = esp_get_free_heap_size();
for (uint32_t i = 0; i <= 3; i++) {
for (uint32_t i = 0; i <= 10; i++) {
TEST_ESP_OK(jpeg_new_decoder_engine(&decode_eng_cfg, &jpgd_handle));
vTaskDelay(10 / portTICK_PERIOD_MS);
TEST_ESP_OK(jpeg_del_decoder_engine(jpgd_handle));