From 29ad4d88cb53cd2997c3787e3436cf1ba7d5ec19 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Sun, 2 Oct 2011 21:19:11 +0200 Subject: [PATCH] Avoid running off a cliff when we get to the end of the list of files --- fr60.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fr60.c b/fr60.c index 35b84b9..9061a4f 100644 --- a/fr60.c +++ b/fr60.c @@ -666,7 +666,7 @@ chevent(uchar chan, uchar event) downloadingfilenum++; } } - if (downloadingfilenum == antfsdir_used) { + if (downloadingfilenum >= antfsdir_used) { printf("No files to download"); } else { D("downloading first file (%d)\n", antfsdir[downloadingfilenum].fileno); @@ -681,7 +681,8 @@ chevent(uchar chan, uchar event) downloadfinished = 1; } else { downloadingfilenum++; - while (! interesting_file(&antfsdir[downloadingfilenum], antfsdir_used)) { + while (downloadingfilenum < antfsdir_used && + ! interesting_file(&antfsdir[downloadingfilenum], antfsdir_used)) { D("Skipping %d; not .fit file\n", downloadingfilenum); downloadingfilenum++; } -- 2.39.5