diff options
author | Scott Jackson <daneren2005@gmail.com> | 2020-10-08 21:09:52 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2020-10-08 21:09:52 -0700 |
commit | 86c012c230b394f04e0d016bb5929438d14794a8 (patch) | |
tree | 44ae4695453be19afe11291e4106adb59ca35aec /app/src | |
parent | 47511702830172f21a31fa12078ef71ba7800098 (diff) | |
download | dsub-86c012c230b394f04e0d016bb5929438d14794a8.tar.gz dsub-86c012c230b394f04e0d016bb5929438d14794a8.tar.bz2 dsub-86c012c230b394f04e0d016bb5929438d14794a8.zip |
Fixed #1021 preload count being max int triggers buffer overflow in getRecentDownloads()
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/DownloadService.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index 77bc2516..67a0f36f 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1083,7 +1083,7 @@ public class DownloadService extends Service { 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); |