]> err.no Git - gant/commitdiff
Avoid running off a cliff when we get to the end of the list of files
authorTollef Fog Heen <tfheen@err.no>
Sun, 2 Oct 2011 19:19:11 +0000 (21:19 +0200)
committerTollef Fog Heen <tfheen@err.no>
Sun, 2 Oct 2011 19:19:11 +0000 (21:19 +0200)
fr60.c

diff --git a/fr60.c b/fr60.c
index 35b84b9f24461c43611edb159d5d414a445ccc7f..9061a4fe8b2149c2408ca3b0234628b5c103874b 100644 (file)
--- 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++;
                                                }