[postgis-tickets] r15727 - #3847, coverity fixes for 2.0
Paul Ramsey
pramsey at cleverelephant.ca
Thu Sep 14 07:08:37 PDT 2017
Author: pramsey
Date: 2017-09-14 07:08:37 -0700 (Thu, 14 Sep 2017)
New Revision: 15727
Modified:
branches/2.0/loader/dbfopen.c
branches/2.0/loader/pgsql2shp-core.c
branches/2.0/loader/shp2pgsql-core.c
branches/2.0/raster/loader/raster2pgsql.c
Log:
#3847, coverity fixes for 2.0
Modified: branches/2.0/loader/dbfopen.c
===================================================================
--- branches/2.0/loader/dbfopen.c 2017-09-14 14:07:14 UTC (rev 15726)
+++ branches/2.0/loader/dbfopen.c 2017-09-14 14:08:37 UTC (rev 15727)
@@ -694,7 +694,11 @@
fp = psHooks->FOpen( pszFullname, "rb+" );
if( fp == NULL )
+ {
+ free(pszBasename);
+ free(pszFullname);
return( NULL );
+ }
sprintf( pszFullname, "%s.cpg", pszBasename );
Modified: branches/2.0/loader/pgsql2shp-core.c
===================================================================
--- branches/2.0/loader/pgsql2shp-core.c 2017-09-14 14:07:14 UTC (rev 15726)
+++ branches/2.0/loader/pgsql2shp-core.c 2017-09-14 14:08:37 UTC (rev 15727)
@@ -831,6 +831,8 @@
fp = fopen( pszFullname, "wb" );
if ( fp == NULL )
{
+ free(pszFullname);
+ free(query);
return 0;
}
result = fputs (srtext,fp);
@@ -1799,7 +1801,10 @@
*/
dbffieldsize = getMaxFieldSize(state->conn, state->schema, state->table, pgfieldname);
if (dbffieldsize == -1)
+ {
+ free(dbffieldname);
return 0;
+ }
if (!dbffieldsize)
dbffieldsize = 32;
@@ -2147,6 +2152,7 @@
{
snprintf(state->message, SHPDUMPERMSGLEN, _("Error parsing HEXEWKB for record %d"), state->currow);
PQclear(state->fetchres);
+ free(hexewkb);
return SHPDUMPERERR;
}
Modified: branches/2.0/loader/shp2pgsql-core.c
===================================================================
--- branches/2.0/loader/shp2pgsql-core.c 2017-09-14 14:07:14 UTC (rev 15726)
+++ branches/2.0/loader/shp2pgsql-core.c 2017-09-14 14:08:37 UTC (rev 15727)
@@ -713,6 +713,9 @@
if ( !mem )
{
+ /* Free the linked list of rings */
+ ReleasePolygons(Outer, polygon_total);
+
snprintf(state->message, SHPLOADERMSGLEN, "unable to write geometry");
return SHPLOADERERR;
}
@@ -1583,10 +1586,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;
}
@@ -1608,6 +1611,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.0/raster/loader/raster2pgsql.c
===================================================================
--- branches/2.0/raster/loader/raster2pgsql.c 2017-09-14 14:07:14 UTC (rev 15726)
+++ branches/2.0/raster/loader/raster2pgsql.c 2017-09-14 14:08:37 UTC (rev 15727)
@@ -433,7 +433,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