[postgis-tickets] r15725 - #3847, coverity fixes for 2.2
Paul Ramsey
pramsey at cleverelephant.ca
Thu Sep 14 07:04:51 PDT 2017
Author: pramsey
Date: 2017-09-14 07:04:51 -0700 (Thu, 14 Sep 2017)
New Revision: 15725
Modified:
branches/2.2/extensions/address_standardizer/gamma.c
branches/2.2/loader/dbfopen.c
branches/2.2/loader/pgsql2shp-core.c
branches/2.2/loader/shp2pgsql-core.c
branches/2.2/raster/loader/raster2pgsql.c
Log:
#3847, coverity fixes for 2.2
Modified: branches/2.2/extensions/address_standardizer/gamma.c
===================================================================
--- branches/2.2/extensions/address_standardizer/gamma.c 2017-09-14 14:01:43 UTC (rev 15724)
+++ branches/2.2/extensions/address_standardizer/gamma.c 2017-09-14 14:04:51 UTC (rev 15725)
@@ -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.2/loader/dbfopen.c
===================================================================
--- branches/2.2/loader/dbfopen.c 2017-09-14 14:01:43 UTC (rev 15724)
+++ branches/2.2/loader/dbfopen.c 2017-09-14 14:04:51 UTC (rev 15725)
@@ -693,7 +693,11 @@
fp = psHooks->FOpen( pszFullname, "rb+" );
if( fp == NULL )
+ {
+ free(pszBasename);
+ free(pszFullname);
return( NULL );
+ }
sprintf( pszFullname, "%s.cpg", pszBasename );
Modified: branches/2.2/loader/pgsql2shp-core.c
===================================================================
--- branches/2.2/loader/pgsql2shp-core.c 2017-09-14 14:01:43 UTC (rev 15724)
+++ branches/2.2/loader/pgsql2shp-core.c 2017-09-14 14:04:51 UTC (rev 15725)
@@ -830,8 +830,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);
@@ -1731,7 +1734,10 @@
*/
dbffieldsize = getMaxFieldSize(state->conn, state->schema, state->table, pgfieldname);
if (dbffieldsize == -1)
+ {
+ free(dbffieldname);
return 0;
+ }
if (!dbffieldsize)
dbffieldsize = 32;
@@ -2079,6 +2085,7 @@
{
snprintf(state->message, SHPDUMPERMSGLEN, _("Error parsing HEXEWKB for record %d"), state->currow);
PQclear(state->fetchres);
+ free(hexewkb);
return SHPDUMPERERR;
}
Modified: branches/2.2/loader/shp2pgsql-core.c
===================================================================
--- branches/2.2/loader/shp2pgsql-core.c 2017-09-14 14:01:43 UTC (rev 15724)
+++ branches/2.2/loader/shp2pgsql-core.c 2017-09-14 14:04:51 UTC (rev 15725)
@@ -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;
}
@@ -1612,10 +1615,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;
}
@@ -1637,6 +1640,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.2/raster/loader/raster2pgsql.c
===================================================================
--- branches/2.2/raster/loader/raster2pgsql.c 2017-09-14 14:01:43 UTC (rev 15724)
+++ branches/2.2/raster/loader/raster2pgsql.c 2017-09-14 14:04:51 UTC (rev 15725)
@@ -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