[postgis-tickets] r15723 - #3847, coverity fixes in topology and address standardizer

Paul Ramsey pramsey at cleverelephant.ca
Thu Sep 14 06:56:57 PDT 2017


Author: pramsey
Date: 2017-09-14 06:56:57 -0700 (Thu, 14 Sep 2017)
New Revision: 15723

Modified:
   trunk/extensions/address_standardizer/gamma.c
   trunk/topology/postgis_topology.c
Log:
#3847, coverity fixes in topology and address standardizer


Modified: trunk/extensions/address_standardizer/gamma.c
===================================================================
--- trunk/extensions/address_standardizer/gamma.c	2017-09-14 13:52:25 UTC (rev 15722)
+++ trunk/extensions/address_standardizer/gamma.c	2017-09-14 13:56:57 UTC (rev 15723)
@@ -152,6 +152,18 @@
     if ( !initialize_link( err_p ,
                            o_l ,
                            EPSILON ) ) {
+
+       /* Cleanup allocated resources */
+       FREE_AND_NULL(o_l);
+       FREE_AND_NULL(k_s);
+       FREE_AND_NULL(r_p);
+
+       PAGC_DESTROY_2D_ARRAY(rules -> Trie,NODE,MAXINSYM);
+       rules -> Trie = NULL;
+
+       rules_free(rules);
+       FREE_AND_NULL(rules);
+
        return NULL ;
     }
 

Modified: trunk/topology/postgis_topology.c
===================================================================
--- trunk/topology/postgis_topology.c	2017-09-14 13:52:25 UTC (rev 15722)
+++ trunk/topology/postgis_topology.c	2017-09-14 13:56:57 UTC (rev 15723)
@@ -170,21 +170,19 @@
   static SPIPlanPtr plan = NULL;
 
   // prepare
-  if ( ! plan ) {
-    sql = "SELECT id,srid,precision,null::geometry"
-                          " FROM topology.topology "
-                          "WHERE name = $1::varchar";
-    argtypes[0] = CSTRINGOID;
-    plan = SPI_prepare(sql, 1, argtypes);
-    if ( ! plan )
-    {
-      cberror(be, "unexpected return (%d) from query preparation: %s",
-              SPI_result, sql);
-      return NULL;
-    }
-    SPI_keepplan(plan);
-    // SPI_freeplan to free, eventually
+  sql = "SELECT id,srid,precision,null::geometry"
+                        " FROM topology.topology "
+                        "WHERE name = $1::varchar";
+  argtypes[0] = CSTRINGOID;
+  plan = SPI_prepare(sql, 1, argtypes);
+  if ( ! plan )
+  {
+    cberror(be, "unexpected return (%d) from query preparation: %s",
+            SPI_result, sql);
+    return NULL;
   }
+  SPI_keepplan(plan);
+  // SPI_freeplan to free, eventually
 
   // execute
   values[0] = CStringGetDatum(name);



More information about the postgis-tickets mailing list