Skip to content

Commit

Permalink
Fixed #1021 preload count being max int triggers buffer overflow in g…
Browse files Browse the repository at this point in the history
…etRecentDownloads()
  • Loading branch information
daneren2005 committed Oct 9, 2020
1 parent 4751170 commit 86c012c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ public synchronized List<DownloadFile> getDownloads() {

public synchronized List<DownloadFile> getRecentDownloads() {
int from = Math.max(currentPlayingIndex - 10, 0);
int songsToKeep = Math.max(Util.getPreloadCount(this), 20);
int songsToKeep = Math.min(Math.max(Util.getPreloadCount(this), 20), downloadList.size());
int to = Math.min(currentPlayingIndex + songsToKeep, Math.max(downloadList.size() - 1, 0));
List<DownloadFile> temp = downloadList.subList(from, to);
temp.addAll(backgroundDownloadList);
Expand Down

0 comments on commit 86c012c

Please sign in to comment.