[geos-commits] r3080 - in trunk: src/geom tests/unit/io
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Jul 8 16:54:50 EDT 2010
Author: strk
Date: 2010-07-08 20:54:50 +0000 (Thu, 08 Jul 2010)
New Revision: 3080
Modified:
trunk/src/geom/Polygon.cpp
trunk/tests/unit/io/WKTReaderTest.cpp
Log:
Object passed for ownership transfer in the constructor shouldn't be deleted when construction fails. Fixes bug #361
Modified: trunk/src/geom/Polygon.cpp
===================================================================
--- trunk/src/geom/Polygon.cpp 2010-07-01 21:49:11 UTC (rev 3079)
+++ trunk/src/geom/Polygon.cpp 2010-07-08 20:54:50 UTC (rev 3080)
@@ -75,8 +75,6 @@
else
{
if (newHoles != NULL && newShell->isEmpty() && hasNonEmptyElements(newHoles)) {
- delete newShell;
- delete newHoles;
throw util::IllegalArgumentException("shell is empty but holes are not");
}
shell=newShell;
@@ -89,8 +87,6 @@
else
{
if (hasNullElements(newHoles)) {
- delete newShell;
- delete newHoles;
throw util::IllegalArgumentException("holes must not contain null elements");
}
for (size_t i=0; i<newHoles->size(); i++)
Modified: trunk/tests/unit/io/WKTReaderTest.cpp
===================================================================
--- trunk/tests/unit/io/WKTReaderTest.cpp 2010-07-01 21:49:11 UTC (rev 3079)
+++ trunk/tests/unit/io/WKTReaderTest.cpp 2010-07-08 20:54:50 UTC (rev 3080)
@@ -11,6 +11,7 @@
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/CoordinateSequence.h>
+#include <geos/util/IllegalArgumentException.h>
// std
#include <sstream>
#include <string>
@@ -119,6 +120,22 @@
std::string("LINESTRING Z (-117.0 33.0 2.0, -116.0 34.0 4.0)") );
}
+ // 6 - invalid WKT (see http://trac.osgeo.org/geos/ticket/361)
+ template<>
+ template<>
+ void object::test<6>()
+ {
+ GeomPtr geom;
+
+ try {
+ geom.reset(wktreader.read("POLYGON( EMPTY, (1 1,2 2,1 2,1 1))"));
+ ensure( !"Didn't get expected exception" );
+ } catch (const geos::util::IllegalArgumentException& ex) {
+ ensure( "Did get expected exception" );
+ } catch (...) {
+ ensure( !"Got unexpected exception" );
+ }
+ }
} // namespace tut
More information about the geos-commits
mailing list