From 88238966fddeb76bd9da91b0e6d962cc8a2bead8 Mon Sep 17 00:00:00 2001 From: Mani <12898705+Maniload@users.noreply.github.com> Date: Mon, 18 Nov 2024 01:24:01 +0100 Subject: [PATCH] fix: Fixed potential memory leak caused by recursive playlists (#227) --- src/pages/playlist/[playlistId]/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pages/playlist/[playlistId]/index.tsx b/src/pages/playlist/[playlistId]/index.tsx index f040378..0e0f15c 100644 --- a/src/pages/playlist/[playlistId]/index.tsx +++ b/src/pages/playlist/[playlistId]/index.tsx @@ -75,6 +75,7 @@ import { UNSORTED, } from "@/utils/comparators"; import createVideoSlug from "@/utils/createVideoSlug"; +import devLog from "@/utils/devLog"; import type { SharedPageProps } from "@/utils/getSharedPageProps"; import getSharedPageProps from "@/utils/getSharedPageProps"; import type { Comparator, RequiredNonNullable } from "@/utils/types"; @@ -163,10 +164,15 @@ function sortLinkedList(list: LinkedList) { const sortedList = []; while (next) { + delete lookUp[next.id]; sortedList.push(next); next = next.next ? lookUp[next.next.id] : undefined; } + if (sortedList.length !== list.length) { + devLog.error("The sorted linked list has a different size as the original list. It probably has broken links!"); + } + return sortedList; }