Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/osgEarth/GEOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ namespace
{
coords->push_back( coords->front() );
}
#if GEOS_VERSION_AT_LEAST(3,8)
geom::CoordinateSequence::Ptr seq = factory->create(coords);
return seq.get();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. Ptr is a unique_ptr so the memory will be freed up as soon as the function is returned.
This function would be returning freed up memory.

seq.release is probably what would work here but there migh be a memory leak

#else
geom::CoordinateSequence* seq = factory->create( coords );

return seq;
#endif
}

geom::Geometry*
Expand Down Expand Up @@ -141,12 +145,20 @@ namespace
if ( shell )
{
const Polygon* poly = static_cast<const Polygon*>(input);
#if GEOS_VERSION_AT_LEAST(3,8)
std::vector<geom::LinearRing*>* holes = poly->getHoles().size() > 0 ? new std::vector<geom::LinearRing*>() : 0L;
#else
std::vector<geom::Geometry*>* holes = poly->getHoles().size() > 0 ? new std::vector<geom::Geometry*>() : 0L;
#endif
if (holes)
{
for( RingCollection::const_iterator r = poly->getHoles().begin(); r != poly->getHoles().end(); ++r )
{
geom::Geometry* hole = import( r->get(), f );
#if GEOS_VERSION_AT_LEAST(3,8)
geom::LinearRing* hole = dynamic_cast<geom::LinearRing*>(import( r->get(), f ));
#else
geom::Geometry* hole = import(r->get(), f);
#endif
if (hole)
{
if (hole->getGeometryTypeId() == geos::geom::GEOS_LINEARRING)
Expand Down