[postgis-tickets] r15726 - #3847, coverity fixes for 2.1
Paul Ramsey
pramsey at cleverelephant.ca
Thu Sep 14 07:07:14 PDT 2017
Author: pramsey
Date: 2017-09-14 07:07:14 -0700 (Thu, 14 Sep 2017)
New Revision: 15726
Modified:
branches/2.1/loader/dbfopen.c
branches/2.1/loader/pgsql2shp-core.c
branches/2.1/loader/shp2pgsql-core.c
branches/2.1/raster/loader/raster2pgsql.c
Log:
#3847, coverity fixes for 2.1
Modified: branches/2.1/loader/dbfopen.c
===================================================================
--- branches/2.1/loader/dbfopen.c 2017-09-14 14:04:51 UTC (rev 15725)
+++ branches/2.1/loader/dbfopen.c 2017-09-14 14:07:14 UTC (rev 15726)
@@ -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.1/loader/pgsql2shp-core.c
===================================================================
--- branches/2.1/loader/pgsql2shp-core.c 2017-09-14 14:04:51 UTC (rev 15725)
+++ branches/2.1/loader/pgsql2shp-core.c 2017-09-14 14:07:14 UTC (rev 15726)
@@ -831,6 +831,8 @@
fp = fopen( pszFullname, "wb" );
if ( fp == NULL )
{
+ free(pszFullname);
+ free(query);
return 0;
}
result = fputs (srtext,fp);
@@ -1812,7 +1814,10 @@
*/
dbffieldsize = getMaxFieldSize(state->conn, state->schema, state->table, pgfieldname);
if (dbffieldsize == -1)
+ {
+ free(dbffieldname);
return 0;
+ }
if (!dbffieldsize)
dbffieldsize = 32;
@@ -2160,6 +2165,7 @@
{
snprintf(state->message, SHPDUMPERMSGLEN, _("Error parsing HEXEWKB for record %d"), state->currow);
PQclear(state->fetchres);
+ free(hexewkb);
return SHPDUMPERERR;
}
Modified: branches/2.1/loader/shp2pgsql-core.c
===================================================================
--- branches/2.1/loader/shp2pgsql-core.c 2017-09-14 14:04:51 UTC (rev 15725)
+++ branches/2.1/loader/shp2pgsql-core.c 2017-09-14 14:07:14 UTC (rev 15726)
@@ -723,6 +723,9 @@
if ( !mem )
{
+ /* Free the linked list of rings */
+ ReleasePolygons(Outer, polygon_total);
+
snprintf(state->message, SHPLOADERMSGLEN, "unable to write geometry");
return SHPLOADERERR;
}
@@ -1593,10 +1596,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;
}
@@ -1618,6 +1621,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.1/raster/loader/raster2pgsql.c
===================================================================
--- branches/2.1/raster/loader/raster2pgsql.c 2017-09-14 14:04:51 UTC (rev 15725)
+++ branches/2.1/raster/loader/raster2pgsql.c 2017-09-14 14:07:14 UTC (rev 15726)
@@ -504,7 +504,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