aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2020-10-08 21:09:52 -0700
committerScott Jackson <daneren2005@gmail.com>2020-10-08 21:09:52 -0700
commit86c012c230b394f04e0d016bb5929438d14794a8 (patch)
tree44ae4695453be19afe11291e4106adb59ca35aec /app/src
parent47511702830172f21a31fa12078ef71ba7800098 (diff)
downloaddsub-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.java2
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);