From: Jeff Lounsbury Date: Tue, 6 Nov 2001 23:03:49 +0000 (+0000) Subject: Fixed the 'free memory that didn't exist problem' from newsgroup feedback X-Git-Tag: pgis_0_6_2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84100b4fd5218d868bf5f71323ecd7ef9d8cf7c8;p=postgis Fixed the 'free memory that didn't exist problem' from newsgroup feedback git-svn-id: http://svn.osgeo.org/postgis/trunk@104 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql.c b/loader/shp2pgsql.c index 421967a04..bf1887111 100644 --- a/loader/shp2pgsql.c +++ b/loader/shp2pgsql.c @@ -353,7 +353,6 @@ int ring_check(SHPObject* obj, char *table, char *sr_id, int rings,DBFHandle hDB temp = Poly; Poly = Poly->next; free(temp->list); - free(temp->next); free(temp); } } @@ -402,7 +401,7 @@ int main (int ARGC, char **ARGV){ int num_entities, phnshapetype,next_ring,errflg,c; double padminbound[8], padmaxbound[8]; int u,j,tot_rings,curindex; - SHPObject *obj; + SHPObject *obj=NULL; char name[12]; char opt; char *sr_id,*shp_file,*table, *database; @@ -555,9 +554,16 @@ int main (int ARGC, char **ARGV){ SHPGetInfo( hSHPHandle, &num_entities, &phnshapetype, &padminbound[0], &padmaxbound[0]); - obj = SHPReadObject(hSHPHandle,0); - trans=0; + if(obj == NULL){ + obj = SHPReadObject(hSHPHandle,0); + if(obj == NULL){ + printf("file exists but contains null shapes"); + exit(-1); + } + } + trans=0; + //create the geometry column with an addgeometry call to dave's function if(opt != 'a'){ @@ -582,7 +588,6 @@ int main (int ARGC, char **ARGV){ } - //Determine what type of shape is in the file and do appropriate processing if (obj->nVertices == 0){ if (dump_format){ printf("\\N"); @@ -598,10 +603,11 @@ int main (int ARGC, char **ARGV){ { + //Determine what type of shape is in the file and do appropriate processing - if( obj->nSHPType == 5 ){ - //--------------------------------------------------------------------------------- - //---------POLYGONS---------------------------------------------------------------- + if( obj->nSHPType == 5 ){ + //--------------------------------------------------------------------------------- + //---------POLYGONS---------------------------------------------------------------- // sorts of all the rings so that they are outer,inner,iner,outer,inner... // with the inner ones coming after the outer ones they are within spatially