summaryrefslogtreecommitdiffstats
path: root/gis/ossim/c0d975.patch
blob: 31423b557a0d18a08f2eac80c079741093633e2e (plain)
From c0d97536f9ac967941b6ca48a6a7a4dde44f4ee3 Mon Sep 17 00:00:00 2001
From: Garrett Potts <gpotts@radiantblue.com>
Date: Thu, 31 Oct 2019 07:42:32 -0400
Subject: [PATCH] Fixed a core dump

---
 src/base/ossimPolyArea2d.cpp | 10 ++++---
 src/init/ossimInit.cpp       | 52 +++---------------------------------
 2 files changed, 9 insertions(+), 53 deletions(-)

diff --git a/src/base/ossimPolyArea2d.cpp b/src/base/ossimPolyArea2d.cpp
index 572d59de..3212b74a 100644
--- a/src/base/ossimPolyArea2d.cpp
+++ b/src/base/ossimPolyArea2d.cpp
@@ -100,6 +100,7 @@ class ossimPolyArea2dPrivate
 void ossimPolyArea2dPrivate::setGeometry(const ossimPolygon &exteriorRing,
                                          const std::vector<ossimPolygon> &interiorRings)
 {
+
    deleteGeometry();
 
    if (exteriorRing.getNumberOfVertices() < 1)
@@ -107,14 +108,15 @@ void ossimPolyArea2dPrivate::setGeometry(const ossimPolygon &exteriorRing,
    GEOSGeometryPtr shell = 0;
    std::vector<GEOSGeometryPtr> holes;
    const std::vector<ossimDpt> &pts = exteriorRing.getVertexList();
-   int idx = 0;
-   int n = (int)pts.size();
+   ossim_int32 idx = 0;
+   ossim_int32 n = (int)pts.size();
 
    bool firstAndLastSame = ((pts[0].x == pts[n - 1].x) && (pts[0].y == pts[n - 1].y));
    if (n > 0)
    {
       GEOSCoordSequence *shellSeq = GEOSCoordSeq_create(
-          exteriorRing.getNumberOfVertices() + ((firstAndLastSame) ? 0 : 1), 2);
+          n + ((firstAndLastSame) ? 0 : 1), 2);
+
       //fill the exterior ring
       for (idx = 0; idx < n; idx++)
       {
@@ -123,7 +125,7 @@ void ossimPolyArea2dPrivate::setGeometry(const ossimPolygon &exteriorRing,
       //if the original polygon didn't have the first and last point the same, make it so
       if (!firstAndLastSame)
       {
-         GEOSCoordSeq_setXY(shellSeq, idx, pts[0].x, pts[0].y);
+         GEOSCoordSeq_setXY(shellSeq, n, pts[0].x, pts[0].y);
       }
       shell = GEOSGeom_createLinearRing(shellSeq);
       //fill the interior rings
diff --git a/src/init/ossimInit.cpp b/src/init/ossimInit.cpp
index 2c2ec2c1..787a49d9 100644
--- a/src/init/ossimInit.cpp
+++ b/src/init/ossimInit.cpp
@@ -195,6 +195,8 @@ void ossimInit::initialize(ossimArgumentParser& parser)
       }
       return;
    }
+   initGEOS(geosNoticeFunction, geosErrorFunction);
+
    theInstance->parseEnvOptions(parser);
    theInstance->parseNotifyOption(parser);
    theInstance->parsePrefsOptions(parser);
@@ -253,7 +255,7 @@ void ossimInit::initialize()
       }
       return;
    }
-   
+
    int argc = 1;
    char* argv[1];
 
@@ -261,54 +263,6 @@ void ossimInit::initialize()
    argv[0][0] = '\0';
    initialize(argc, argv);
    delete [] argv[0];
-
-#if 0   
-    static std::mutex m;
-   std::lock_guard<std::mutex> lock(m);
-   if(theInitializedFlag)
-   {
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "DEBUG ossimInit::initialize(): Already initialized, returning......" << std::endl;
-      }
-      return;
-   }
-
-   theInstance->theAppName  = "";
-   theInstance->thePreferences = ossimPreferences::instance();
-   theInstance->initializeDefaultFactories();
-   
-   if ( theElevEnabledFlag )
-   {
-      theInstance->initializeElevation();
-   }
-
-   theInstance->initializeLogFile();
-
-   //---
-   // To do:
-   // We need a mechanism to register factories to the "front" or the
-   // "back" of factory list so that plugins can override things.  For
-   // now we will initialize the plugins last...
-   //---
-   if(thePluginLoaderEnabledFlag)
-   {
-      theInstance->initializePlugins();
-   }
-
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossim preferences file: "
-         << theInstance->thePreferences->getPreferencesFilename()
-         << "\nVersion: " << version()
-         << "\nossimInit::initialize() leaving..."
-         << std::endl;
-   } 
-   
-   theInitializedFlag = true;
-#endif
 }
 
 void ossimInit::finalize()