different segfault with lastest master

Linus Torvalds torvalds at linux-foundation.org
Mon Jul 13 14:25:23 PDT 2015


On Mon, Jul 13, 2015 at 1:58 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> The problem is that "nr" is not necessarily 0 or 1, because we may
> have *previous* taxonomy data, and we keep potentially growing it.

So I'm testing the attached patch, but so far I haven't seen anything.

As mentioned, I'm not sure what triggers it.

                         Linus
-------------- next part --------------
 divesitehelpers.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/divesitehelpers.cpp b/divesitehelpers.cpp
index 775951855925..dedc2a0477b1 100644
--- a/divesitehelpers.cpp
+++ b/divesitehelpers.cpp
@@ -152,11 +152,14 @@ void ReverseGeoLookupThread::run() {
 			if (oceanName["name"].isValid()) {
 				if (ds->taxonomy.category == NULL)
 					ds->taxonomy.category = alloc_taxonomy();
-				ds->taxonomy.category[ds->taxonomy.nr].category = TC_OCEAN;
-				ds->taxonomy.category[ds->taxonomy.nr].origin = taxonomy::GEOCODED;
-				ds->taxonomy.category[ds->taxonomy.nr].value = copy_string(qPrintable(oceanName["name"].toString()));
-				ds->taxonomy.nr++;
-				mark_divelist_changed(true);
+				if (ds->taxonomy.nr < TC_NR_CATEGORIES) {
+					ds->taxonomy.category[ds->taxonomy.nr].category = TC_OCEAN;
+					ds->taxonomy.category[ds->taxonomy.nr].origin = taxonomy::GEOCODED;
+					ds->taxonomy.category[ds->taxonomy.nr].value = copy_string(qPrintable(oceanName["name"].toString()));
+					ds->taxonomy.nr++;
+					mark_divelist_changed(true);
+				} else
+					qDebug() << "Too many taxonomies" << ds->taxonomy.nr << "\n";
 			}
 		} else {
 			report_error("timeout accessing geonames.org");


More information about the subsurface mailing list