From 40de3816ec960ea647441a8529fe478f219e2aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20M=C3=BAdry?= Date: Tue, 12 Mar 2024 13:25:09 +0100 Subject: [PATCH] fix(fatfs): Fix leak of malloced FIL struct In esp_vfs_fat_create_contiguous_file and esp_vfs_fat_test_contiguous_file functions --- components/fatfs/vfs/vfs_fat.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/fatfs/vfs/vfs_fat.c b/components/fatfs/vfs/vfs_fat.c index 5fff8b573d..c67845131a 100644 --- a/components/fatfs/vfs/vfs_fat.c +++ b/components/fatfs/vfs/vfs_fat.c @@ -1348,10 +1348,12 @@ esp_err_t esp_vfs_fat_create_contiguous_file(const char* base_path, const char* } _lock_release(&fat_ctx->lock); + free(file); return 0; fail: _lock_release(&fat_ctx->lock); + free(file); ESP_LOGD(TAG, "%s: fresult=%d", __func__, res); errno = fresult_to_errno(res); return -1; @@ -1432,10 +1434,12 @@ esp_err_t esp_vfs_fat_test_contiguous_file(const char* base_path, const char* fu } _lock_release(&fat_ctx->lock); + free(file); return 0; fail: _lock_release(&fat_ctx->lock); + free(file); ESP_LOGD(TAG, "%s: fresult=%d", __func__, res); errno = fresult_to_errno(res); return -1;