From: Mark Cave-Ayland Date: Fri, 1 Jul 2011 22:36:48 +0000 (+0000) Subject: Another attempt to fix #1080 on Windows - it seems that simply opening and X-Git-Tag: 2.0.0alpha1~1295 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9bb000bbcc5676306df3099299db3c195a8db48e;p=postgis Another attempt to fix #1080 on Windows - it seems that simply opening and closing a pgsql2shp state object is a good way to find all uninitialised variables. git-svn-id: http://svn.osgeo.org/postgis/trunk@7547 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/pgsql2shp-core.c b/loader/pgsql2shp-core.c index b98548460..985a1f310 100644 --- a/loader/pgsql2shp-core.c +++ b/loader/pgsql2shp-core.c @@ -1259,6 +1259,11 @@ ShpDumperCreate(SHPDUMPERCONFIG *config) state->schema = NULL; state->table = NULL; state->geo_col_name = NULL; + state->fetch_query = NULL; + state->main_scan_query = NULL; + state->dbffieldnames = NULL; + state->dbffieldtypes = NULL; + state->pgfieldnames = NULL; state->column_map_pgfieldnames = NULL; state->column_map_dbffieldnames = NULL; state->column_map_size = 0; @@ -2242,15 +2247,24 @@ ShpDumperDestroy(SHPDUMPERSTATE *state) PQfinish(state->conn); /* Free the query strings */ - free(state->fetch_query); - free(state->main_scan_query); + if (state->fetch_query) + free(state->fetch_query); + if (state->main_scan_query) + free(state->main_scan_query); /* Free the DBF information fields */ - for (i = 0; i < state->fieldcount; i++) - free(state->dbffieldnames[i]); - free(state->dbffieldnames); - free(state->dbffieldtypes); - free(state->pgfieldnames); + if (state->dbffieldnames) + { + for (i = 0; i < state->fieldcount; i++) + free(state->dbffieldnames[i]); + free(state->dbffieldnames); + } + + if (state->dbffieldtypes) + free(state->dbffieldtypes); + + if (state->pgfieldnames) + free(state->pgfieldnames); /* Free any column map fieldnames if specified */ if (state->column_map_size > 0)