diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index 46890e3e64c..918b1e6d294 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -139,8 +139,8 @@ esp_err_t esp_vfs_register_fd_range(const esp_vfs_t *vfs, void *ctx, int min_fd, _lock_acquire(&s_fd_table_lock); for (int i = min_fd; i < max_fd; ++i) { if (s_fd_table[i].vfs_index != -1) { - free(s_vfs[i]); - s_vfs[i] = NULL; + free(s_vfs[index]); + s_vfs[index] = NULL; for (int j = min_fd; j < i; ++j) { if (s_fd_table[j].vfs_index == index) { s_fd_table[j] = FD_TABLE_ENTRY_UNUSED;