]> granicus.if.org Git - postgis/commitdiff
Fix for bug #2272: shp2pgsql-gui crashes when given filenames with dots.
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 13 Apr 2013 17:36:22 +0000 (17:36 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 13 Apr 2013 17:36:22 +0000 (17:36 +0000)
This was a combination of two bugs: firstly, we weren't initialising the
state variable field_names to NULL, and so if the variable happened to
be filled with junk and we were unable to import a shape file, we would
end up freeing a random pointer.

Secondly, shapelib tries to be clever and strip off any file extension
by searching for a "." character from the end of the filename, hence
causing the truncation of the filename. Resolve this by leaving the
.shp/.dbf extension from the file selector in the filename string so
that shapelib does the right thing.

git-svn-id: http://svn.osgeo.org/postgis/trunk@11292 b70326c6-7e19-0410-871a-916f4a2858ee

loader/shp2pgsql-core.c
loader/shp2pgsql-gui.c

index 9be37360da9447ff14ccc8ba59e80c36d2e1c72c..0ed441bd30890d77b052a9308cd2dbe1bc50a505 100644 (file)
@@ -792,6 +792,7 @@ ShpLoaderCreate(SHPLOADERCONFIG *config)
        state->widths = NULL;
        state->precisions = NULL;
        state->col_names = NULL;
+       state->field_names = NULL;
 
        state->from_srid = config->shp_sr_id;
        state->to_srid = config->sr_id;
index 13b46f3e030fa3d90910aa41459dbeca4da3d2d3..fc27fa79c6e40674b9454794764edc8455230720 100644 (file)
@@ -931,9 +931,6 @@ create_new_file_config(const char *filename)
        table_end = loader_file_config->shp_file + strlen(loader_file_config->shp_file);
        while (*table_end != '.' && table_end > loader_file_config->shp_file && table_end > table_start )
                table_end--;
-       
-       /* Sneakily remove .shp from shp_file */
-       *table_end = '\0';
 
        /* Copy the table name */
        loader_file_config->table = malloc(table_end - table_start + 1);