[postgis-tickets] r15678 - initialize state->num_fields and state->pgfieldtypes on shape file create otherwise cunit ends up with a garbage huge number for state->num_fields which I think causes the crash I am seeing sometimes.

Regina Obe lr at pcorp.us
Sun Sep 10 18:51:42 PDT 2017


Author: robe
Date: 2017-09-10 18:51:41 -0700 (Sun, 10 Sep 2017)
New Revision: 15678

Modified:
   trunk/loader/shp2pgsql-core.c
Log:
initialize state->num_fields and state->pgfieldtypes on shape file create otherwise cunit ends up with a garbage huge number for state->num_fields which I think causes the crash I am seeing sometimes. 

References #3839 for PostGIS 2.4.0

Modified: trunk/loader/shp2pgsql-core.c
===================================================================
--- trunk/loader/shp2pgsql-core.c	2017-09-10 12:01:56 UTC (rev 15677)
+++ trunk/loader/shp2pgsql-core.c	2017-09-11 01:51:41 UTC (rev 15678)
@@ -784,6 +784,8 @@
 	state->precisions = NULL;
 	state->col_names = NULL;
 	state->field_names = NULL;
+	state->num_fields = NULL;
+	state->pgfieldtypes = NULL;
 
 	state->from_srid = config->shp_sr_id;
 	state->to_srid = config->sr_id;
@@ -1075,6 +1077,7 @@
 
 	/* Get the field information from the DBF */
 	state->num_fields = DBFGetFieldCount(state->hDBFHandle);
+
 	state->num_records = DBFGetRecordCount(state->hDBFHandle);
 
 	/* Allocate storage for field information */
@@ -1864,7 +1867,6 @@
 {
 	/* Destroy a state object created with ShpLoaderOpenShape */
 	int i;
-
 	if (state != NULL)
 	{
 		if (state->hSHPHandle)



More information about the postgis-tickets mailing list