[postgis-tickets] r15683 - initialize state->num_fields and state->pgfieldtypes so doesn't cause intermittent crashes on windows
Regina Obe
lr at pcorp.us
Mon Sep 11 08:50:07 PDT 2017
Author: robe
Date: 2017-09-11 08:50:06 -0700 (Mon, 11 Sep 2017)
New Revision: 15683
Modified:
branches/2.3/NEWS
branches/2.3/loader/shp2pgsql-core.c
Log:
initialize state->num_fields and state->pgfieldtypes so doesn't cause intermittent crashes on windows
Closes #3839 for PostGIS 2.3.4
Modified: branches/2.3/NEWS
===================================================================
--- branches/2.3/NEWS 2017-09-11 15:16:01 UTC (rev 15682)
+++ branches/2.3/NEWS 2017-09-11 15:50:06 UTC (rev 15683)
@@ -14,6 +14,8 @@
and partitioned tables
- #3806, Reverse geocoder missing suffix direction when present
- #3698, loading census tabblock is broken
+ - #3839, loader tests sometimes crash because of variables not initialized
+ also reenable cunit loader tess to always run.
PostGIS 2.3.3
Modified: branches/2.3/loader/shp2pgsql-core.c
===================================================================
--- branches/2.3/loader/shp2pgsql-core.c 2017-09-11 15:16:01 UTC (rev 15682)
+++ branches/2.3/loader/shp2pgsql-core.c 2017-09-11 15:50:06 UTC (rev 15683)
@@ -248,7 +248,7 @@
{
/* Create a ptarray containing a single point */
POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, 1);
-
+
/* Generate the point */
point4d.x = obj->padfX[u];
point4d.y = obj->padfY[u];
@@ -294,7 +294,7 @@
/* Free all of the allocated items */
lwgeom_free(lwgeom);
-
+
/* Return the string - everything ok */
*geometry = mem;
@@ -639,7 +639,7 @@
for (pi = 0; pi < polygon_total; pi++)
{
LWPOLY *lwpoly = lwpoly_construct_empty(state->from_srid, state->has_z, state->has_m);
-
+
Ring *polyring;
int ring_index = 0;
@@ -779,11 +779,13 @@
state->hDBFHandle = NULL;
state->has_z = 0;
state->has_m = 0;
+ state->num_fields = 0;
state->types = NULL;
state->widths = NULL;
state->precisions = NULL;
state->col_names = NULL;
state->field_names = NULL;
+ state->pgfieldtypes = NULL;
state->from_srid = config->shp_sr_id;
state->to_srid = config->sr_id;
@@ -856,8 +858,8 @@
return SHPLOADERERR;
}
-
-
+
+
/* Open the column map if one was specified */
if (state->config->column_map_filename)
{
@@ -865,7 +867,7 @@
&state->column_map, state->message, SHPLOADERMSGLEN);
if (!ret) return SHPLOADERERR;
}
-
+
/* User hasn't altered the default encoding preference... */
if ( strcmp(state->config->encoding, ENCODING_DEFAULT) == 0 )
{
@@ -1023,7 +1025,7 @@
break;
}
-
+
/* Force Z/M-handling if configured to do so */
switch(state->config->force_output)
{
@@ -1121,7 +1123,7 @@
strncpy(name, utf8str, MAXFIELDNAMELEN);
free(utf8str);
}
-
+
/* If a column map file has been passed in, use this to create the postgresql field name from
the dbf column name */
{
@@ -1192,7 +1194,7 @@
if (state->config->forceint4 || (state->widths[j] >=5 && state->widths[j] < 10))
{
state->pgfieldtypes[j] = malloc(strlen("int4") + 1);
- strcpy(state->pgfieldtypes[j], "int4");
+ strcpy(state->pgfieldtypes[j], "int4");
}
else if (state->widths[j] < 5)
{
@@ -1229,7 +1231,7 @@
snprintf(state->message, SHPLOADERMSGLEN, _("Invalid type %x in DBF file"), state->types[j]);
return SHPLOADERERR;
}
-
+
strcat(state->col_names, "\"");
strcat(state->col_names, name);
@@ -1267,13 +1269,13 @@
for handling string resizing during append */
sb = stringbuffer_create();
stringbuffer_clear(sb);
-
+
/* Set the client encoding if required */
if (state->config->encoding)
{
stringbuffer_aprintf(sb, "SET CLIENT_ENCODING TO UTF8;\n");
}
-
+
/* Use SQL-standard string escaping rather than PostgreSQL standard */
stringbuffer_aprintf(sb, "SET STANDARD_CONFORMING_STRINGS TO ON;\n");
@@ -1344,7 +1346,7 @@
/* First output the raw field type string */
stringbuffer_aprintf(sb, "%s", state->pgfieldtypes[j]);
-
+
/* Some types do have typmods though... */
if (!strcmp("varchar", state->pgfieldtypes[j]))
stringbuffer_aprintf(sb, "(%d)", state->widths[j]);
@@ -1679,7 +1681,7 @@
{
/* Force the locale to C */
char *oldlocale = setlocale(LC_NUMERIC, "C");
-
+
/* Handle the case of a NULL shape */
if (obj->nVertices == 0)
{
@@ -1772,7 +1774,7 @@
/* Tidy up everything */
SHPDestroyObject(obj);
-
+
setlocale(LC_NUMERIC, oldlocale);
}
@@ -1866,7 +1868,7 @@
{
/* Destroy a state object created with ShpLoaderOpenShape */
int i;
-
+
if (state != NULL)
{
if (state->hSHPHandle)
@@ -1884,7 +1886,7 @@
{
for (i = 0; i < state->num_fields; i++)
free(state->pgfieldtypes[i]);
-
+
free(state->pgfieldtypes);
}
if (state->types)
@@ -1898,7 +1900,7 @@
/* Free any column map fieldnames if specified */
colmap_clean(&state->column_map);
-
+
/* Free the state itself */
free(state);
}
More information about the postgis-tickets
mailing list