aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-03 14:56:38 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-03-05 13:03:43 -0800
commit9b5f6e16e1ec89ca8f5478e9da0d9a3a67bbf249 (patch)
treed9e3f1ef27f13780e9746de8c46ccebdb80ad15d
parente4a1991e0c8f24930200c00d5509a63e9aa41fad (diff)
downloadsubsurface-9b5f6e16e1ec89ca8f5478e9da0d9a3a67bbf249.tar.gz
Import: fix infinite loop
Owing to a variable reuse in a nested loop, importing dive logs with new trips could lead to an infinite loop. Use a fresh index "j". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/divelist.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/divelist.c b/core/divelist.c
index 6a8f78f0f..f22544c0d 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -1673,7 +1673,7 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table *
struct dive_table *dives_to_add, struct dive_table *dives_to_remove,
struct trip_table *trips_to_add)
{
- int i, nr, start_renumbering_at = 0;
+ int i, j, nr, start_renumbering_at = 0;
struct dive_trip *trip_import, *new_trip;
int preexisting;
bool sequence_changed = false;
@@ -1740,8 +1740,8 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table *
/* If no trip to merge-into was found, add trip as-is.
* First, add dives to list of dives to add */
- for (i = 0; i < trip_import->dives.nr; i++) {
- struct dive *d = trip_import->dives.dives[i];
+ for (j = 0; j < trip_import->dives.nr; j++) {
+ struct dive *d = trip_import->dives.dives[j];
/* Add dive to list of dives to-be-added. */
insert_dive(dives_to_add, d);