fix(fatfs): Fix leak of malloced FIL struct

In esp_vfs_fat_create_contiguous_file and esp_vfs_fat_test_contiguous_file functions
pull/13306/head
Adam Múdry 2024-03-12 13:25:09 +01:00
rodzic 2973e7acba
commit 40de3816ec
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -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;