[prev in list] [next in list] [prev in thread] [next in thread]
List: geos-commits
Subject: [geos-commits] r2697 - trunk/source/linearref
From: svn_geos () osgeo ! org
Date: 2009-10-23 10:13:13
Message-ID: 20091023101313.0ABD5E0112B () lists ! osgeo ! org
[Download RAW message or body]
Author: strk
Date: 2009-10-23 06:13:12 -0400 (Fri, 23 Oct 2009)
New Revision: 2697
Modified:
trunk/source/linearref/LinearGeometryBuilder.cpp
Log:
Fix memory access error (#283)
Modified: trunk/source/linearref/LinearGeometryBuilder.cpp
===================================================================
--- trunk/source/linearref/LinearGeometryBuilder.cpp 2009-10-23 10:03:22 UTC (rev 2696)
+++ trunk/source/linearref/LinearGeometryBuilder.cpp 2009-10-23 10:13:12 UTC (rev 2697)
@@ -29,6 +29,8 @@
#include <geos/linearref/LinearGeometryBuilder.h>
#include <geos/util/IllegalArgumentException.h>
+#include <cassert>
+
using namespace std;
using namespace geos::geom;
@@ -105,7 +107,17 @@
}
else if (fixInvalidLines)
{
- add((*coordList)[0]);
+ assert(!coordList->isEmpty()); // just to be sure
+
+ // NOTE: we copy the point cause reallocation of
+ // vector memory will invalidate the reference
+ // to one of its elements.
+ //
+ // We wouldn't have such problems with a vector
+ // of pointers (as used in JTS)...
+ //
+ Coordinate firstPoint = (*coordList)[0];
+ add(firstPoint);
}
}
_______________________________________________
geos-commits mailing list
geos-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic