[postgis-tickets] r15724 - #3847, coverity fixes for 2.3
Paul Ramsey
pramsey at cleverelephant.ca
Thu Sep 14 07:01:43 PDT 2017
Author: pramsey
Date: 2017-09-14 07:01:43 -0700 (Thu, 14 Sep 2017)
New Revision: 15724
Modified:
branches/2.3/extensions/address_standardizer/gamma.c
branches/2.3/loader/dbfopen.c
branches/2.3/loader/pgsql2shp-core.c
branches/2.3/loader/shp2pgsql-core.c
branches/2.3/raster/loader/raster2pgsql.c
Log:
#3847, coverity fixes for 2.3
Modified: branches/2.3/extensions/address_standardizer/gamma.c
===================================================================
--- branches/2.3/extensions/address_standardizer/gamma.c 2017-09-14 13:56:57 UTC (rev 15723)
+++ branches/2.3/extensions/address_standardizer/gamma.c 2017-09-14 14:01:43 UTC (rev 15724)
@@ -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: branches/2.3/loader/dbfopen.c
===================================================================
--- branches/2.3/loader/dbfopen.c 2017-09-14 13:56:57 UTC (rev 15723)
+++ branches/2.3/loader/dbfopen.c 2017-09-14 14:01:43 UTC (rev 15724)
@@ -686,14 +686,22 @@
/* -------------------------------------------------------------------- */
fp = psHooks->FOpen( pszFullname, "wb" );
if( fp == NULL )
+ {
+ free(pszBasename);
+ free(pszFullname);
return( NULL );
+ }
psHooks->FWrite( &chZero, 1, 1, fp );
psHooks->FClose( fp );
fp = psHooks->FOpen( pszFullname, "rb+" );
if( fp == NULL )
+ {
+ free(pszBasename);
+ free(pszFullname);
return( NULL );
+ }
sprintf( pszFullname, "%s.cpg", pszBasename );
Modified: branches/2.3/loader/pgsql2shp-core.c
===================================================================
--- branches/2.3/loader/pgsql2shp-core.c 2017-09-14 13:56:57 UTC (rev 15723)
+++ branches/2.3/loader/pgsql2shp-core.c 2017-09-14 14:01:43 UTC (rev 15724)
@@ -831,8 +831,11 @@
fp = fopen( pszFullname, "wb" );
if ( fp == NULL )
{
+ free(pszFullname);
+ free(query);
return 0;
}
+ else
{
result = fputs (srtext,fp);
LWDEBUGF(3, "\n result %d proj SRText is %s .\n", result, srtext);
@@ -1738,7 +1741,10 @@
*/
dbffieldsize = getMaxFieldSize(state->conn, state->schema, state->table, pgfieldname);
if (dbffieldsize == -1)
+ {
+ free(dbffieldname);
return 0;
+ }
if (!dbffieldsize)
dbffieldsize = 32;
@@ -2087,6 +2093,7 @@
{
snprintf(state->message, SHPDUMPERMSGLEN, _("Error parsing HEXEWKB for record %d"), state->currow);
PQclear(state->fetchres);
+ free(hexewkb);
return SHPDUMPERERR;
}
Modified: branches/2.3/loader/shp2pgsql-core.c
===================================================================
--- branches/2.3/loader/shp2pgsql-core.c 2017-09-14 13:56:57 UTC (rev 15723)
+++ branches/2.3/loader/shp2pgsql-core.c 2017-09-14 14:01:43 UTC (rev 15724)
@@ -703,6 +703,9 @@
if ( !mem )
{
+ /* Free the linked list of rings */
+ ReleasePolygons(Outer, polygon_total);
+
snprintf(state->message, SHPLOADERMSGLEN, "unable to write geometry");
return SHPLOADERERR;
}
@@ -1614,10 +1617,10 @@
default:
snprintf(state->message, SHPLOADERMSGLEN, _("Error: field %d has invalid or unknown field type (%d)"), i, state->types[i]);
+ /* clean up and return err */
SHPDestroyObject(obj);
stringbuffer_destroy(sbwarn);
stringbuffer_destroy(sb);
-
return SHPLOADERERR;
}
@@ -1639,6 +1642,10 @@
if ( rv == UTF8_BAD_RESULT )
free(utf8str);
+ /* clean up and return err */
+ SHPDestroyObject(obj);
+ stringbuffer_destroy(sbwarn);
+ stringbuffer_destroy(sb);
return SHPLOADERERR;
}
strncpy(val, utf8str, MAXVALUELEN);
Modified: branches/2.3/raster/loader/raster2pgsql.c
===================================================================
--- branches/2.3/raster/loader/raster2pgsql.c 2017-09-14 13:56:57 UTC (rev 15723)
+++ branches/2.3/raster/loader/raster2pgsql.c 2017-09-14 14:01:43 UTC (rev 15724)
@@ -511,7 +511,7 @@
init_rastinfo(RASTERINFO *info) {
info->srid = SRID_UNKNOWN;
info->srs = NULL;
- memset(info->dim, 0, sizeof(double) * 2);
+ memset(info->dim, 0, sizeof(uint32_t) * 2);
info->nband_count = 0;
info->nband = NULL;
info->gdalbandtype = NULL;
More information about the postgis-tickets
mailing list