fix: Fixed potential memory leak caused by recursive playlists (#227)

This commit is contained in:
Mani
2024-11-18 01:24:01 +01:00
committed by GitHub
parent 7a8326706f
commit 88238966fd
@@ -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<T>(list: LinkedList<T>) {
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;
}