From: Regina Obe Date: Mon, 11 Sep 2017 01:51:41 +0000 (+0000) Subject: initialize state->num_fields and state->pgfieldtypes on shape file create otherwise... X-Git-Tag: 2.4.0rc1~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3818d6231419cc1f4eb658c1ddf1da0e1fa2a525;p=postgis 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 git-svn-id: http://svn.osgeo.org/postgis/trunk@15678 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index c081ef572..63f8ecb16 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -784,6 +784,8 @@ ShpLoaderCreate(SHPLOADERCONFIG *config) 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 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state) /* 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 @@ ShpLoaderDestroy(SHPLOADERSTATE *state) { /* Destroy a state object created with ShpLoaderOpenShape */ int i; - if (state != NULL) { if (state->hSHPHandle)