From 218567bb86f485c9ff7b851e2d9034cf6c4968ba Mon Sep 17 00:00:00 2001 From: Salvador Cuñat Date: Thu, 25 Jul 2019 21:28:57 +0200 Subject: fix site/location build issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were assuming these tables were sorted with their indexes, but it happens to be false, under some circustances at least. Reported-by: Andreas Hagberg Signed-off-by: Salvador Cuñat --- smtk-import/smartrak.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'smtk-import') diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index 1787d3fb7..4ed87a646 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -334,8 +334,9 @@ static void smtk_build_location(MdbHandle *mdb, char *idx, struct dive_site **lo if (!table) return; - for (i = 1; i <= atoi(idx); i++) + do { mdb_fetch_row(table); + } while (strcasecmp(col[0]->bind_ptr, idx)); loc_idx = copy_string(col[2]->bind_ptr); site = copy_string(col[1]->bind_ptr); loc = create_location(strtod(col[6]->bind_ptr, NULL), strtod(col[7]->bind_ptr, NULL)); @@ -360,8 +361,10 @@ static void smtk_build_location(MdbHandle *mdb, char *idx, struct dive_site **lo /* Read data from Location table, linked to Site by loc_idx */ table = smtk_open_table(mdb, "Location", col, bound_values); mdb_rewind_table(table); - for (i = 1; i <= atoi(loc_idx); i++) + do { mdb_fetch_row(table); + } while (strcasecmp(col[0]->bind_ptr, loc_idx)); + /* * Create a string for Subsurface's dive site structure with coordinates * if available, if the site's name doesn't previously exists. -- cgit v1.2.3-70-g09d2