From 9b5f6e16e1ec89ca8f5478e9da0d9a3a67bbf249 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 3 Mar 2019 14:56:38 +0100 Subject: 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 --- core/divelist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core') 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); -- cgit v1.2.3-70-g09d2