Просмотр исходного кода

Added missing checks for Vect_open_* return value to avoid potential segmentation fault

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60054 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 11 лет назад
Родитель
Сommit
67014631cb
92 измененных файлов с 431 добавлено и 179 удалено
  1. 7 2
      display/d.extract/main.c
  2. 2 1
      display/d.path/main.c
  3. 2 1
      display/d.vect.chart/main.c
  4. 3 1
      general/manage/lister/vector.c
  5. 5 2
      lib/sites/sites.c
  6. 5 2
      lib/vector/Vlib/build.c
  7. 6 3
      lib/vector/Vlib/map.c
  8. 4 1
      lib/vector/Vlib/open.c
  9. 4 6
      ps/ps.map/do_vectors.c
  10. 2 1
      raster/r.carve/main.c
  11. 4 1
      raster/r.carve/vect.c
  12. 3 1
      raster/r.contour/main.c
  13. 2 1
      raster/r.le/r.le.setup/sample.c
  14. 3 4
      raster/r.random/random.c
  15. 4 1
      raster/r.random/support.c
  16. 2 1
      raster/r.stream.extract/close.c
  17. 6 2
      raster/r.stream.order/stream_vector.c
  18. 6 2
      raster/r.stream.segment/stream_vector.c
  19. 5 2
      raster/r.stream.snap/points_io.c
  20. 2 4
      raster/r.to.vect/main.c
  21. 2 1
      raster/r.volume/main.c
  22. 5 2
      raster/simwe/simlib/output.c
  23. 9 5
      vector/v.buffer/main.c
  24. 4 2
      vector/v.build.polylines/main.c
  25. 10 3
      vector/v.build/main.c
  26. 2 1
      vector/v.class/main.c
  27. 8 3
      vector/v.clean/main.c
  28. 4 2
      vector/v.clean/test/topocheck.c
  29. 2 1
      vector/v.colors.out/make_colors.c
  30. 3 1
      vector/v.colors.out/scan_cats.c
  31. 3 1
      vector/v.colors/main.c
  32. 2 1
      vector/v.db.connect/main.c
  33. 4 3
      vector/v.db.select/main.c
  34. 2 1
      vector/v.delaunay/main.c
  35. 8 3
      vector/v.distance/main.c
  36. 7 2
      vector/v.drape/main.c
  37. 3 1
      vector/v.edit/main.c
  38. 4 2
      vector/v.external/main.c
  39. 6 2
      vector/v.extract/main.c
  40. 7 2
      vector/v.extrude/main.c
  41. 3 1
      vector/v.in.ascii/main.c
  42. 3 3
      vector/v.in.db/main.c
  43. 2 1
      vector/v.in.dwg/main.c
  44. 2 1
      vector/v.in.lidar/main.c
  45. 7 2
      vector/v.in.ogr/main.c
  46. 3 1
      vector/v.in.region/main.c
  47. 3 1
      vector/v.in.sites/main.c
  48. 9 3
      vector/v.kernel/main.c
  49. 2 1
      vector/v.label.sa/labels.c
  50. 2 1
      vector/v.label/main.c
  51. 13 5
      vector/v.lrs/v.lrs.create/main.c
  52. 4 2
      vector/v.lrs/v.lrs.label/main.c
  53. 4 2
      vector/v.lrs/v.lrs.segment/main.c
  54. 4 2
      vector/v.lrs/v.lrs.where/main.c
  55. 3 1
      vector/v.neighbors/main.c
  56. 5 2
      vector/v.net.alloc/main.c
  57. 6 2
      vector/v.net.iso/main.c
  58. 2 1
      vector/v.net.path/main.c
  59. 7 2
      vector/v.net.salesman/main.c
  60. 7 2
      vector/v.net.steiner/main.c
  61. 3 1
      vector/v.normal/main.c
  62. 2 1
      vector/v.out.dxf/main.c
  63. 4 1
      vector/v.out.ogr/main.c
  64. 2 1
      vector/v.out.pov/main.c
  65. 2 1
      vector/v.out.svg/main.c
  66. 8 3
      vector/v.overlay/main.c
  67. 6 2
      vector/v.parallel/main.c
  68. 16 7
      vector/v.patch/main.c
  69. 6 3
      vector/v.perturb/main.c
  70. 6 2
      vector/v.proj/main.c
  71. 6 2
      vector/v.qcount/main.c
  72. 5 2
      vector/v.reclass/main.c
  73. 6 2
      vector/v.rectify/main.c
  74. 8 2
      vector/v.sample/main.c
  75. 7 2
      vector/v.segment/main.c
  76. 10 2
      vector/v.select/main.c
  77. 6 2
      vector/v.split/main.c
  78. 3 1
      vector/v.surf.idw/read_sites.c
  79. 7 4
      vector/v.surf.rst/main.c
  80. 2 1
      vector/v.to.db/main.c
  81. 8 2
      vector/v.to.points/main.c
  82. 7 3
      vector/v.to.rast/support.c
  83. 3 1
      vector/v.to.rast/vect2rast.c
  84. 3 1
      vector/v.to.rast3/main.c
  85. 4 2
      vector/v.transform/main.c
  86. 3 1
      vector/v.type/main.c
  87. 3 1
      vector/v.univar/main.c
  88. 4 2
      vector/v.vect.stats/main.c
  89. 9 5
      vector/v.vol.rst/main.c
  90. 4 2
      vector/v.voronoi/main.c
  91. 3 2
      vector/v.what.rast/main.c
  92. 2 1
      vector/v.what.rast3/main.c

+ 7 - 2
display/d.extract/main.c

@@ -98,8 +98,13 @@ int main(int argc, char **argv)
 	G_fatal_error(_("Vector map <%s> not found"), input->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&In, input->answer, mapset);
-    Vect_open_new(&Out, output->answer, Vect_is_3d(&In));
+
+    if (Vect_open_old(&In, input->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), input->answer);
+
+    if (Vect_open_new(&Out, output->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output->answer);
+
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);

+ 2 - 1
display/d.path/main.c

@@ -184,7 +184,8 @@ int main(int argc, char **argv)
 	geo = 0;
 
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, "");
+    if (Vect_open_old(&Map, map->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map->answer);
 
     D_setup(0);
 

+ 2 - 1
display/d.vect.chart/main.c

@@ -243,7 +243,8 @@ int main(int argc, char **argv)
 
     /* open vector */
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map_opt->answer, "");
+    if (Vect_open_old(&Map, map_opt->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map_opt->answer);
 
     ctype = CTYPE_PIE;
     if (ctype_opt->answer[0] == 'b')

+ 3 - 1
general/manage/lister/vector.c

@@ -2,6 +2,7 @@
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/vector.h>
+#include <grass/glocale.h>
 
 int main(int argc, char *argv[])
 {
@@ -19,7 +20,8 @@ int lister(char *name, char *mapset, char *title)
 
     *title = 0;
     if (*name) {
-	Vect_open_old_head(&Map, name, mapset);
+	if (Vect_open_old_head(&Map, name, mapset) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), name);
 	strcpy(title, Vect_get_map_name(&Map));
 	Vect_close(&Map);
     }

+ 5 - 2
lib/sites/sites.c

@@ -258,7 +258,9 @@ struct Map_info *G_sites_open_old(const char *name, const char *mapset)
     Map = (struct Map_info *)G_malloc(sizeof(struct Map_info));
 
     Vect_set_open_level(1);
-    Vect_open_old(Map, name, mapset);
+
+    if (Vect_open_old(Map, name, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), name);
 
     G_debug(1, "Vector map opened");
 
@@ -388,7 +390,8 @@ struct Map_info *G_sites_open_new(const char *name)
 
     Map = (struct Map_info *)G_malloc(sizeof(struct Map_info));
 
-    Vect_open_new(Map, name, 0);
+    if (Vect_open_new(Map, name, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), name);
 
     G_debug(1, "New vector map opened");
 

+ 5 - 2
lib/vector/Vlib/build.c

@@ -838,8 +838,11 @@ int Vect_build_partial(struct Map_info *Map, int build)
         /* don't write support files for OGR direct and PostGIS Topology */
 	Map->support_updated = TRUE;
 
-    if (!Map->plus.Spidx_built)
-	Vect_open_sidx(Map, 2);
+    if (!Map->plus.Spidx_built) {
+	if (Vect_open_sidx(Map, 2) < 0)
+	    G_fatal_error(_("Unable to open spatial index file for vector map <%s>"),
+			    Vect_get_full_name(Map));
+    }
 
     plus = &(Map->plus);
     if (build > GV_BUILD_NONE && !Map->temporary) {

+ 6 - 3
lib/vector/Vlib/map.c

@@ -155,7 +155,8 @@ int Vect_copy(const char *in, const char *mapset, const char *out)
 
     /* Open input */
     Vect_set_open_level(1);
-    Vect_open_old_head(&In, in, mapset);
+    if (Vect_open_old_head(&In, in, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in);
 
     if (In.format != GV_FORMAT_NATIVE) {        /* Done */
         Vect_close(&In);
@@ -164,7 +165,8 @@ int Vect_copy(const char *in, const char *mapset, const char *out)
 
     /* Open output */
     Vect_set_open_level(1);
-    Vect_open_update_head(&Out, out, G_mapset());
+    if (Vect_open_update_head(&Out, out, G_mapset()) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), out);
 
     /* Copy tables */
     n = Vect_get_num_dblinks(&In);
@@ -276,7 +278,8 @@ int Vect_rename(const char *in, const char *out)
 
     /* Rename all tables if the format is native */
     Vect_set_open_level(1);
-    Vect_open_update_head(&Map, out, G_mapset());
+    if (Vect_open_update_head(&Map, out, G_mapset()) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), out);
 
     if (Map.format != GV_FORMAT_NATIVE) {       /* Done */
         Vect_close(&Map);

+ 4 - 1
lib/vector/Vlib/open.c

@@ -859,7 +859,9 @@ int open_new(struct Map_info *Map, const char *name, int with_z, int is_tmp)
     dig_init_plus(&(Map->plus));
 
     /* open new spatial index */
-    Vect_open_sidx(Map, 2);
+    if (Vect_open_sidx(Map, 2) < 0)
+	G_fatal_error(_("Unable to open spatial index file for vector map <%s>"),
+			Vect_get_full_name(Map));
 
     Map->open = VECT_OPEN_CODE;
     Map->head_only = FALSE;
@@ -1164,6 +1166,7 @@ int Vect_open_topo(struct Map_info *Map, int head_only)
   \param[in,out] Map pointer to Map_info
   \param mode 0 old, 1 update, 2 new
   
+  \return 1 if sidx file is not available
   \return 0 on success
   \return -1 on error
 */

+ 4 - 6
ps/ps.map/do_vectors.c

@@ -34,9 +34,8 @@ int do_vectors(int after_masking)
 		  vector.layer[n].name, vector.layer[n].mapset);
 
 	Vect_set_open_level(2);
-	if (2 >
-	    Vect_open_old(&Map, vector.layer[n].name,
-			  vector.layer[n].mapset)) {
+	if (2 > Vect_open_old(&Map, vector.layer[n].name,
+				vector.layer[n].mapset)) {
 	    char name[100];
 
 	    sprintf(name, "%s in %s", vector.layer[n].name,
@@ -138,9 +137,8 @@ int do_vpoints(int after_masking)
 		  vector.layer[n].name, vector.layer[n].mapset);
 
 	Vect_set_open_level(2);
-	if (2 >
-	    Vect_open_old(&Map, vector.layer[n].name,
-			  vector.layer[n].mapset)) {
+	if (2 > Vect_open_old(&Map, vector.layer[n].name,
+				vector.layer[n].mapset)) {
 	    char name[100];
 
 	    sprintf(name, "%s in %s", vector.layer[n].name,

+ 2 - 1
raster/r.carve/main.c

@@ -158,7 +158,8 @@ int main(int argc, char **argv)
 	G_fatal_error(_("Vector map <%s> not found"), parm.invect->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&Map, parm.invect->answer, vmapset);
+    if (Vect_open_old(&Map, parm.invect->answer, vmapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), parm.invect->answer);
 
     if ((rmapset = G_find_file2("cell", parm.inrast->answer, "")) == NULL)
 	G_fatal_error(_("Raster map <%s> not found"), parm.inrast->answer);

+ 4 - 1
raster/r.carve/vect.c

@@ -19,6 +19,7 @@
 
 #include <stdio.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
 #include "enforce.h"
 
 
@@ -27,7 +28,9 @@
  */
 int open_new_vect(struct Map_info *map, char *vect)
 {
-    Vect_open_new(map, vect, 1);
+    if (Vect_open_new(map, vect, 1) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), vect);
+
     Vect_set_map_name(map, vect);
     Vect_set_comment(map, G_recreate_command());
     Vect_hist_command(map);

+ 3 - 1
raster/r.contour/main.c

@@ -149,7 +149,9 @@ int main(int argc, char *argv[])
     /* get window info */
     G_get_window(&Wind);
 
-    Vect_open_new(&Map, vect->answer, 1);
+    if (Vect_open_new(&Map, vect->answer, 1) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), vect->answer);
+
     Vect_hist_command(&Map);
 
     db_init_string(&sql);

+ 2 - 1
raster/r.le/r.le.setup/sample.c

@@ -1033,7 +1033,8 @@ static int calc_unit_loc(double radius, int top, int bot, int left, int right,
 	    exit(0);
 	}
 
-	Vect_open_old(&Map, sites_file_name, sites_mapset);
+	if (Vect_open_old(&Map, sites_file_name, sites_mapset) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), sites_file_name);
 	/*    fprintf(stderr, "\n    Can't open vector points file %s\n", sites_file_name); */
 
 	*sites = 0;

+ 3 - 4
raster/r.random/random.c

@@ -59,10 +59,9 @@ int execute_random(struct rr_state *theState)
     }
 
     if (theState->outvector) {
-	if (theState->z_geometry)
-	    Vect_open_new(&Out, theState->outvector, 1);
-	else
-	    Vect_open_new(&Out, theState->outvector, 0);
+	if (Vect_open_new(&Out, theState->outvector, theState->z_geometry) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"),
+			    theState->outvector);
 	Vect_hist_command(&Out);
 
 	fi = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);

+ 4 - 1
raster/r.random/support.c

@@ -1,6 +1,7 @@
 #include <grass/gis.h>
 #include <grass/raster.h>
 #include <grass/vector.h>
+#include <grass/glocale.h>
 #include "local_proto.h"
 
 
@@ -58,7 +59,9 @@ int make_support(struct rr_state *theState, int percent, double percentage)
     if (theState->outvector) {
 	struct Map_info map;
 
-	Vect_open_old(&map, theState->outvector, G_mapset());
+	if (Vect_open_old(&map, theState->outvector, G_mapset()) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"),
+			    theState->outvector);
 	Vect_hist_command(&map);
 	Vect_close(&map);
     }

+ 2 - 1
raster/r.stream.extract/close.c

@@ -33,7 +33,8 @@ int close_streamvect(char *stream_vect)
 
     G_message(_("Writing vector map <%s>..."), stream_vect);
 
-    Vect_open_new(&Out, stream_vect, 0);
+    if (Vect_open_new(&Out, stream_vect, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), stream_vect);
     
     nodestack = (struct sstack *)G_malloc(stack_step * sizeof(struct sstack));
 

+ 6 - 2
raster/r.stream.order/stream_vector.c

@@ -17,7 +17,9 @@ int ram_create_vector(CELL ** streams, CELL ** dirs, char *out_vector,
     G_get_window(&window);
     Segments = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
-    Vect_open_new(&Out, out_vector, 0);
+
+    if (Vect_open_new(&Out, out_vector, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_vector);
 
     Vect_reset_line(Segments);
     Vect_reset_cats(Cats);
@@ -102,7 +104,9 @@ int seg_create_vector(SEGMENT * streams, SEGMENT * dirs, char *out_vector,
     G_get_window(&window);
     Segments = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
-    Vect_open_new(&Out, out_vector, 0);
+    
+    if (Vect_open_new(&Out, out_vector, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_vector);
 
     Vect_reset_line(Segments);
     Vect_reset_cats(Cats);

+ 6 - 2
raster/r.stream.segment/stream_vector.c

@@ -24,7 +24,9 @@ int create_sector_vector(char *out_vector, int number_of_streams, int radians)
 
     Segments = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
-    Vect_open_new(&Out, out_vector, 0);
+    
+    if (Vect_open_new(&Out, out_vector, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_vector);
 
     Vect_reset_line(Segments);
     Vect_reset_cats(Cats);
@@ -183,7 +185,9 @@ int create_segment_vector(char *out_vector, int number_of_streams,
 
     Segments = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
-    Vect_open_new(&Out, out_vector, 0);
+    
+    if (Vect_open_new(&Out, out_vector, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_vector);
 
     Vect_reset_line(Segments);
     Vect_reset_cats(Cats);

+ 5 - 2
raster/r.stream.snap/points_io.c

@@ -15,7 +15,8 @@ int read_points(char *in_point, SEGMENT * streams, SEGMENT * accum)
     sites = Vect_new_line_struct();
     cats = Vect_new_cats_struct();
 
-    Vect_open_old(&Map, in_point, "");
+    if (Vect_open_old(&Map, in_point, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_point);
     
     G_get_window(&window);
     Vect_region_box(&window, &box);
@@ -82,7 +83,9 @@ int write_points(char *out_vector, int number_of_points)
     G_get_window(&window);
     Segments = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
-    Vect_open_new(&Out, out_vector, 0);
+    
+    if (Vect_open_new(&Out, out_vector, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_vector);
 
     Vect_reset_line(Segments);
     Vect_reset_cats(Cats);

+ 2 - 4
raster/r.to.vect/main.c

@@ -144,10 +144,8 @@ int main(int argc, char *argv[])
 	G_warning(_("Categories will be unique sequence, raster values will be lost."));
     }
 
-    if (z_flg->answer)
-	Vect_open_new(&Map, out_opt->answer, 1);
-    else
-	Vect_open_new(&Map, out_opt->answer, 0);
+    if (Vect_open_new(&Map, out_opt->answer, z_flg->answer) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
 
     Vect_hist_command(&Map);
 

+ 2 - 1
raster/r.volume/main.c

@@ -150,7 +150,8 @@ int main(int argc, char *argv[])
     
     /* initialize vector map (for centroids) if needed */
     if (centroidsmap) {
-	Vect_open_new(fd_centroids, centroidsmap, WITHOUT_Z);
+	if (Vect_open_new(fd_centroids, centroidsmap, WITHOUT_Z) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"), centroidsmap);
         
         Points = Vect_new_line_struct();
         Cats = Vect_new_cats_struct();

+ 5 - 2
raster/simwe/simlib/output.c

@@ -34,11 +34,14 @@ void output_walker_as_vector(int tt_minutes, int ndigit, struct TimeStamp *times
 	if (ts == 1) {
 	    G_snprintf(buf, sizeof(buf), "%s_%.*d", outwalk, ndigit, tt_minutes);
 	    outwalk_time = G_store(buf);
-	    Vect_open_new(&Out, outwalk_time, WITH_Z);
+	    if (Vect_open_new(&Out, outwalk_time, WITH_Z) < 0)
+		G_fatal_error(_("Unable to create vector map <%s>"),
+				outwalk_time);
 	    G_message("Writing %i walker into vector file %s", nstack, outwalk_time);
 	}
 	else {
-	    Vect_open_new(&Out, outwalk, WITH_Z);
+	    if (Vect_open_new(&Out, outwalk, WITH_Z) < 0)
+		G_fatal_error(_("Unable to create vector map <%s>"), outwalk);
 	    G_message("Writing %i walker into vector file %s", nstack, outwalk);
 	}
 

+ 9 - 5
vector/v.buffer/main.c

@@ -326,7 +326,10 @@ int main(int argc, char *argv[])
     Vect_check_input_output_name(in_opt->answer, out_opt->answer, G_FATAL_EXIT);
 
     Vect_set_open_level(2); /* topology required */
-    Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+
+    if (Vect_open_old2(&In, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
     Vect_set_error_handler_io(&In, &Out);
 
     if (field_opt->answer)
@@ -377,7 +380,8 @@ int main(int argc, char *argv[])
 	G_verbose_message(_("The tolerance in map units = %g"), unit_tolerance);
     }
 
-    Vect_open_new(&Out, out_opt->answer, WITHOUT_Z);
+    if (Vect_open_new(&Out, out_opt->answer, WITHOUT_Z) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
     
     Points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
@@ -385,9 +389,9 @@ int main(int argc, char *argv[])
     CCats = Vect_new_cats_struct();
     
     /* open tmp vector for buffers, needed for cleaning */
-    if (0 > Vect_open_tmp_new(&Buf, NULL, WITHOUT_Z)) {
-        G_fatal_error(_("Unable to create vector map"));
-    }
+    if (0 > Vect_open_tmp_new(&Buf, NULL, WITHOUT_Z))
+        G_fatal_error(_("Unable to create temporary vector map"));
+
     G_set_verbose(0);
     Vect_build_partial(&Buf, GV_BUILD_BASE); /* switch to level 2 */
     G_set_verbose(verbose);

+ 4 - 2
vector/v.build.polylines/main.c

@@ -145,11 +145,13 @@ int main(int argc, char **argv)
 
     /* Open binary vector map at level 2 */
     Vect_set_open_level(2);
-    Vect_open_old(&map, input->answer, "");
+    if (Vect_open_old(&map, input->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), input->answer);
 
     /* Open new vector */
     G_find_vector2(output->answer, "");
-    Vect_open_new(&Out, output->answer, Vect_is_3d(&map));
+    if (Vect_open_new(&Out, output->answer, Vect_is_3d(&map)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output->answer);
 
     /* Copy header info. */
     Vect_copy_head_data(&map, &Out);

+ 10 - 3
vector/v.build/main.c

@@ -113,7 +113,9 @@ int main(int argc, char *argv[])
 	    }
 	}
 	Vect_set_open_level(1);
-	Vect_open_old(&Map, map_opt->answer, G_mapset());
+
+	if (Vect_open_old(&Map, map_opt->answer, G_mapset()) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), map_opt->answer);
         
 	Vect_build(&Map);
     }
@@ -121,7 +123,10 @@ int main(int argc, char *argv[])
     if (dump || sdump || cdump || fdump) {
 	if (!build) {
 	    Vect_set_open_level(2);
-	    Vect_open_old(&Map, map_opt->answer, "");
+
+	    if (Vect_open_old(&Map, map_opt->answer, "") < 0)
+		G_fatal_error(_("Unable to open vector map <%s>"),
+				map_opt->answer);
 	}
 	if (dump)
 	    Vect_topo_dump(&Map, stdout);
@@ -145,7 +150,9 @@ int main(int argc, char *argv[])
 	Points = Vect_new_line_struct();
 	Cats = Vect_new_cats_struct();
 
-	Vect_open_new(&Err, err_opt->answer, Vect_is_3d(&Map));
+	if (Vect_open_new(&Err, err_opt->answer, Vect_is_3d(&Map)) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"),
+			    err_opt->answer);
 
 	nlines = Vect_get_num_lines(&Map);
 

+ 2 - 1
vector/v.class/main.c

@@ -98,7 +98,8 @@ int main(int argc, char *argv[])
     
     /* open input vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, map_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&Map, map_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map_opt->answer);
 
     ofield = Vect_get_field_number(&Map, field_opt->answer);
 

+ 8 - 3
vector/v.clean/main.c

@@ -274,16 +274,21 @@ int main(int argc, char *argv[])
      * virtual centroids (shapefile/OGR) and level 1 is better if input is too big 
      * and build in previous module (like v.in.ogr or other call to v.clean) would take 
      * a long time */
-    Vect_open_old2(&In, opt.in->answer, "", opt.field->answer);
+    if (Vect_open_old2(&In, opt.in->answer, "", opt.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.in->answer);
 
     with_z = Vect_is_3d(&In);
     
-    Vect_open_new(&Out, opt.out->answer, with_z);
+    if (Vect_open_new(&Out, opt.out->answer, with_z) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), opt.out->answer);
+
     Vect_set_error_handler_io(&In, &Out);
 
     if (opt.err->answer) {
 	Vect_set_open_level(2);
-	Vect_open_new(&Err, opt.err->answer, with_z);
+	if (Vect_open_new(&Err, opt.err->answer, with_z) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"),
+			    opt.err->answer);
         G_add_error_handler(error_handler_err, &Err);
 	pErr = &Err;
     }

+ 4 - 2
vector/v.clean/test/topocheck.c

@@ -63,7 +63,8 @@ int main(int argc, char *argv[])
 	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    if (Vect_open_old(&In, in_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
 
     with_z = Vect_is_3d(&In);
 
@@ -82,7 +83,8 @@ int main(int argc, char *argv[])
 	Vect_close(&In);
 	Vect_close(&Out);
 
-	Vect_open_update(&Out, out_opt->answer, G_mapset());
+	if (Vect_open_update(&Out, out_opt->answer, G_mapset()) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), out_opt->answer);
 
 	/* Count number of areas and total area in input */
 	nareas1 = Vect_get_num_areas(&Out);

+ 2 - 1
vector/v.colors.out/make_colors.c

@@ -19,7 +19,8 @@ struct Colors *make_colors(const char *name, const char *layer,
     dbCatVal *cv;
     
     Vect_set_open_level(1); /* no topology required */
-    Vect_open_old2(&Map, name, "", layer);
+    if (Vect_open_old2(&Map, name, "", layer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), name);
 
     field = Vect_get_field_number(&Map, layer);
     if (field < 1)

+ 3 - 1
vector/v.colors.out/scan_cats.c

@@ -16,7 +16,9 @@ void scan_cats(const char *name, const char *layer,
     *cmin = *cmax = -1;
 
     Vect_set_open_level(1); /* no topology required */
-    Vect_open_old2(&Map, name, "", layer);
+    if (Vect_open_old2(&Map, name, "", layer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), name);
+
     ilayer = Vect_get_field_number(&Map, layer);
     if (ilayer < 1)
 	G_fatal_error(_("Layer <%s> not found"), layer);

+ 3 - 1
vector/v.colors/main.c

@@ -260,7 +260,9 @@ int main(int argc, char *argv[])
 
     /* open map and get min/max values */
     Vect_set_open_level(1); /* no topology required */
-    Vect_open_old2(&Map, name, mapset, opt.field->answer);
+    if (Vect_open_old2(&Map, name, mapset, opt.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), name);
+
     Vect_set_error_handler_io(&Map, NULL);
     if (use == USE_Z && !Vect_is_3d(&Map))
         G_fatal_error(_("Vector map <%s> is not 3D"), Vect_get_full_name(&Map));

+ 2 - 1
vector/v.db.connect/main.c

@@ -147,7 +147,8 @@ int main(int argc, char **argv)
 
     Vect_set_open_level(1); /* no topology needed */
     if (print->answer || shell_print->answer || columns->answer) {
-	Vect_open_old2(&Map, inopt->answer, "", field_opt->answer);
+	if (Vect_open_old2(&Map, inopt->answer, "", field_opt->answer) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), inopt->answer);
     }
     else {
 	if (Vect_open_update_head(&Map, inopt->answer, G_mapset()) < 1)

+ 4 - 3
vector/v.db.select/main.c

@@ -138,9 +138,10 @@ int main(int argc, char **argv)
     db_init_string(&value_string);
 
     /* open input vector */
-    if (!r_flag->answer)
-	Vect_open_old_head2(&Map, map_opt->answer, "", field_opt->answer);
-    else {
+    if (!r_flag->answer) {
+	if (Vect_open_old_head2(&Map, map_opt->answer, "", field_opt->answer) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), map_opt->answer);
+    } else {
 	if (2 > Vect_open_old2(&Map, map_opt->answer, "", field_opt->answer)) {
 	    Vect_close(&Map);
 	    G_fatal_error(_("Unable to open vector map <%s> at topology level. "

+ 2 - 1
vector/v.delaunay/main.c

@@ -116,7 +116,8 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
     
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&In, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
 
     /* check if we have a 3D input points map */
     mode3d = Vect_is_3d(&In);

+ 8 - 3
vector/v.distance/main.c

@@ -288,7 +288,8 @@ int main(int argc, char *argv[])
 
     /* Open 'from' vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&From, opt.from->answer, G_mapset(), opt.from_field->answer);
+    if (Vect_open_old2(&From, opt.from->answer, G_mapset(), opt.from_field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.from->answer);
 
     from_field = Vect_get_field_number(&From, opt.from_field->answer);
 
@@ -306,7 +307,8 @@ int main(int argc, char *argv[])
     
     /* Open 'to' vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&To, opt.to->answer, "", opt.to_field->answer);
+    if (Vect_open_old2(&To, opt.to->answer, "", opt.to_field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.to->answer);
 
     ntolines = Vect_get_num_primitives(&To, to_type);
     ntoareas = 0;
@@ -326,7 +328,10 @@ int main(int argc, char *argv[])
 
     /* Open output vector */
     if (opt.out->answer) {
-	Vect_open_new(&Out, opt.out->answer, WITHOUT_Z);
+	if (Vect_open_new(&Out, opt.out->answer, WITHOUT_Z) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"),
+			    opt.out->answer);
+
 	Vect_hist_command(&Out);
 	Outp = &Out;
     }

+ 7 - 2
vector/v.drape/main.c

@@ -137,7 +137,10 @@ int main(int argc, char *argv[])
     
     /* open input vector map */
     Vect_set_open_level(2); /* topology required ? */
-    Vect_open_old2(&In, opt.input->answer, "", opt.layer->answer);
+
+    if (Vect_open_old2(&In, opt.input->answer, "", opt.layer->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.input->answer);
+
     Vect_set_error_handler_io(&In, &Out);
     
     /* get layer number */
@@ -150,7 +153,9 @@ int main(int argc, char *argv[])
     }
 
     /* create output */
-    Vect_open_new(&Out, opt.output->answer, WITH_Z);
+    if (Vect_open_new(&Out, opt.output->answer, WITH_Z) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"),
+			opt.output->answer);
 
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);

+ 3 - 1
vector/v.edit/main.c

@@ -235,7 +235,9 @@ int main(int argc, char *argv[])
 	    }
 	    Vect_close(&Map);
 
-	    Vect_open_update2(&Map, params.map->answer, G_mapset(), params.fld->answer);
+	    if (Vect_open_update2(&Map, params.map->answer, G_mapset(), params.fld->answer) < 0)
+		G_fatal_error(_("Unable to open vector map <%s>"),
+				params.map->answer);
 	}
     }
 

+ 4 - 2
vector/v.external/main.c

@@ -142,7 +142,8 @@ int main(int argc, char *argv[])
     
     /* create new vector map */
     putenv("GRASS_VECTOR_EXTERNAL_IGNORE=1");
-    Vect_open_new(&Map, output, WITHOUT_Z); /* dimension is set later from data source */
+    if (Vect_open_new(&Map, output, WITHOUT_Z) < 0) /* dimension is set later from data source */
+	G_fatal_error(_("Unable to create vector map <%s>"), output);
     Vect_set_error_handler_io(NULL, &Map);
     
     Vect_hist_command(&Map);
@@ -186,7 +187,8 @@ int main(int argc, char *argv[])
     
     if (!flags.topo->answer) {
         Vect_set_open_level(1);
-        Vect_open_old(&Map, output, G_mapset());
+        if (Vect_open_old(&Map, output, G_mapset()) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), output);
         Vect_build(&Map);
         Vect_close(&Map);
     }

+ 6 - 2
vector/v.extract/main.c

@@ -183,7 +183,9 @@ int main(int argc, char **argv)
 
     /* Do initial read of input file */
     Vect_set_open_level(2); /* topology required */
-    Vect_open_old2(&In, input, "", opt.field->answer);
+
+    if (Vect_open_old2(&In, input, "", opt.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), input);
     
     field = Vect_get_field_number(&In, opt.field->answer);
     
@@ -341,7 +343,9 @@ int main(int argc, char **argv)
 	qsort(cat_array, cat_count, sizeof(int), cmp);
     }
 
-    Vect_open_new(&Out, output, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, output, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output);
+
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 

+ 7 - 2
vector/v.extrude/main.c

@@ -184,12 +184,17 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
 
     Vect_set_open_level(2); /* topology required for input */
+
     /* opening input vector map */
-    Vect_open_old2(&In, opt.input->answer, "", opt.field->answer);
+    if (Vect_open_old2(&In, opt.input->answer, "", opt.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.input->answer);
+
     Vect_set_error_handler_io(&In, &Out);
 
     /* creating output vector map */
-    Vect_open_new(&Out, opt.output->answer, WITH_Z);
+    if (Vect_open_new(&Out, opt.output->answer, WITH_Z) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"),
+			opt.output->answer);
 
     field = Vect_get_field_number(&In, opt.field->answer);
 

+ 3 - 1
vector/v.in.ascii/main.c

@@ -227,7 +227,9 @@ int main(int argc, char *argv[])
 	zcoor = 1;
     }
 
-    Vect_open_new(&Map, new->answer, zcoor);
+    if (Vect_open_new(&Map, new->answer, zcoor) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), new->answer);
+
     Vect_set_error_handler_io(NULL, &Map);
     Vect_hist_command(&Map);
 

+ 3 - 3
vector/v.in.db/main.c

@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
 	Vect_set_open_level(1); /* no topo needed */
 
 	if (strcmp(mapset, G_mapset()) == 0 && G_find_vector2(name, mapset) &&
-	    Vect_open_old(&Map, name, mapset)) {
+	    Vect_open_old(&Map, name, mapset) >= 0) {
 	    int num_dblinks;
 
 	    num_dblinks = Vect_get_num_dblinks(&Map);
@@ -147,8 +147,8 @@ int main(int argc, char *argv[])
 	}
     }
 
-    if (Vect_open_new(&Map, outvect->answer, with_z) == -1)
-	G_fatal_error(_("Unable to create new vector map <%s>"),
+    if (Vect_open_new(&Map, outvect->answer, with_z) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"),
 			outvect->answer);
 
     Vect_set_error_handler_io(NULL, &Map);

+ 2 - 1
vector/v.in.dwg/main.c

@@ -196,7 +196,8 @@ int main(int argc, char *argv[])
 
 
     /* open output vector */
-    Vect_open_new(&Map, out_opt->answer, z_flag->answer);
+    if (Vect_open_new(&Map, out_opt->answer, z_flag->answer) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
 
     Vect_hist_command(&Map);
 

+ 2 - 1
vector/v.in.lidar/main.c

@@ -489,7 +489,8 @@ int main(int argc, char *argv[])
     sprintf(buf, "%s", out_opt->answer);
     /* strip any @mapset from vector output name */
     G_find_vector(buf, G_mapset());
-    Vect_open_new(&Map, out_opt->answer, 1);
+    if (Vect_open_new(&Map, out_opt->answer, 1) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
 
     Vect_hist_command(&Map);
     

+ 7 - 2
vector/v.in.ogr/main.c

@@ -856,7 +856,10 @@ int main(int argc, char *argv[])
     /* open output vector */
     /* strip any @mapset from vector output name */
     G_find_vector(output, G_mapset());
-    Vect_open_new(&Map, output, with_z);
+
+    if (Vect_open_new(&Map, output, with_z) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output);
+
     Out = &Map;
 
     if (!flag.no_clean->answer) {
@@ -865,7 +868,9 @@ int main(int argc, char *argv[])
 	     * at the end copy alive lines to output vector
 	     * in case of polygons this reduces the coor file size by a factor of 2 to 5
 	     * only needed when cleaning polygons */
-	    Vect_open_tmp_new(&Tmp, NULL, with_z);
+	    if (Vect_open_tmp_new(&Tmp, NULL, with_z) < 0)
+		G_fatal_error(_("Unable to create temporary vector map"));
+
 	    G_verbose_message(_("Using temporary vector <%s>"), Vect_get_name(&Tmp));
 	    Out = &Tmp;
 	}

+ 3 - 1
vector/v.in.region/main.c

@@ -71,7 +71,9 @@ int main(int argc, char **argv)
     mid_long = (window.west + window.east) / 2;
 
     /* Open output segments */
-    Vect_open_new(&Out, out_opt->answer, 0);
+    if (Vect_open_new(&Out, out_opt->answer, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
+
     Vect_hist_command(&Out);
 
     /* Rectangle */

+ 3 - 1
vector/v.in.sites/main.c

@@ -119,7 +119,9 @@ int main(int argc, char *argv[])
     else
 	withz = 0;
 
-    Vect_open_new(&Map, outvect->answer, withz);
+    if (Vect_open_new(&Map, outvect->answer, withz) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), outvect->answer);
+
     Vect_hist_command(&Map);
 
     fi = Vect_default_field_info(&Map, 1, NULL, GV_1TABLE);

+ 9 - 3
vector/v.kernel/main.c

@@ -306,7 +306,8 @@ int main(int argc, char **argv)
     
     /* Open input vector */
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, "");
+    if (Vect_open_old(&In, in_opt->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
 
     if (net_opt->answer) {
 	int nlines, line;
@@ -317,11 +318,16 @@ int main(int argc, char **argv)
 	dimension = 1.;
 	/* Open input network */
 	Vect_set_open_level(2);
-	Vect_open_old(&Net, net_opt->answer, "");
+
+	if (Vect_open_old(&Net, net_opt->answer, "") < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), net_opt->answer);
+
 	Vect_net_build_graph(&Net, GV_LINES, 0, 0, NULL, NULL, NULL, 0, 0);
 
 	if (!flag_q->answer) {
-	    Vect_open_new(&Out, out_opt->answer, 0);
+	    if (Vect_open_new(&Out, out_opt->answer, 0) < 0)
+		G_fatal_error(_("Unable to create vector map <%s>"),
+				out_opt->answer);
 	    Vect_hist_command(&Out);
 	}
 

+ 2 - 1
vector/v.label.sa/labels.c

@@ -54,7 +54,8 @@ label_t *labels_init(struct params *p, int *n_labels)
     legal_types = Vect_option_to_types(p->type);
 
     /* open vector for read only */
-    Vect_open_old(&Map, p->map->answer, "");
+    if (Vect_open_old(&Map, p->map->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), p->map->answer);
 
     label_sz = Vect_get_num_primitives(&Map, legal_types);
 

+ 2 - 1
vector/v.label/main.c

@@ -264,7 +264,8 @@ int main(int argc, char **argv)
     }
 
     /* open vector */
-    Vect_open_old(&Map, Vectfile->answer, "");
+    if (Vect_open_old(&Map, Vectfile->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), Vectfile->answer);
 
     /* open database */
     field = atoi(Fieldopt->answer);

+ 13 - 5
vector/v.lrs/v.lrs.create/main.c

@@ -250,21 +250,29 @@ int main(int argc, char **argv)
     if (mapset == NULL)
 	G_fatal_error(_("Vector map <%s> not found"), in_lines_opt->answer);
 
-    Vect_open_old(&In, in_lines_opt->answer, mapset);
+    if (Vect_open_old(&In, in_lines_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"),
+			in_lines_opt->answer);
 
     /* Open input ipoints */
     mapset = G_find_vector2(points_opt->answer, NULL);
     if (mapset == NULL)
 	G_fatal_error(_("Vector map <%s> not found"), points_opt->answer);
 
-    Vect_open_old(&PMap, points_opt->answer, mapset);
+    if (Vect_open_old(&PMap, points_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), points_opt->answer);
 
     /* Open output lines */
-    Vect_open_new(&Out, out_lines_opt->answer, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, out_lines_opt->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"),
+			out_lines_opt->answer);
 
     /* Open output error map */
-    if (err_opt->answer)
-	Vect_open_new(&EMap, err_opt->answer, Vect_is_3d(&In));
+    if (err_opt->answer) {
+	if (Vect_open_new(&EMap, err_opt->answer, Vect_is_3d(&In)) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"),
+			    err_opt->answer);
+    }
 
     /* Because the line feature identified by one id (lidcol) may be split
      *  to more line parts, and milepost may be in threshold for more such parts,

+ 4 - 2
vector/v.lrs/v.lrs.label/main.c

@@ -287,10 +287,12 @@ int main(int argc, char **argv)
 	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    if (Vect_open_old(&In, in_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
 
     /* Open output segments */
-    Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
 
     /* open labels */
     labels = NULL;

+ 4 - 2
vector/v.lrs/v.lrs.segment/main.c

@@ -140,10 +140,12 @@ int main(int argc, char **argv)
 	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&In, in_opt->answer, mapset);
+    if (Vect_open_old(&In, in_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
 
     /* Open output segments */
-    Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
 
     db_init_handle(&rshandle);
     db_init_string(&rsstmt);

+ 4 - 2
vector/v.lrs/v.lrs.where/main.c

@@ -127,7 +127,8 @@ int main(int argc, char **argv)
 	G_fatal_error(_("Vector map <%s> not found"), lines_opt->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&LMap, lines_opt->answer, mapset);
+    if (Vect_open_old(&LMap, lines_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), lines_opt->answer);
 
     /* Open input points */
     mapset = G_find_vector2(points_opt->answer, NULL);
@@ -135,7 +136,8 @@ int main(int argc, char **argv)
 	G_fatal_error(_("Vector map <%s> not found"), points_opt->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&PMap, points_opt->answer, mapset);
+    if (Vect_open_old(&PMap, points_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), points_opt->answer);
 
     db_init_handle(&rshandle);
     db_init_string(&rsstmt);

+ 3 - 1
vector/v.neighbors/main.c

@@ -83,7 +83,9 @@ int main(int argc, char *argv[])
 
     /* open input vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&In, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
     field = Vect_get_field_number(&In, field_opt->answer);
 
     G_get_set_window(&region);

+ 5 - 2
vector/v.net.alloc/main.c

@@ -137,7 +137,8 @@ int main(int argc, char **argv)
 	geo = 0;
 
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, "");
+    if (Vect_open_old(&Map, map->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map->answer);
 
     afield = Vect_get_field_number(&Map, afield_opt->answer);
     nfield = Vect_get_field_number(&Map, nfield_opt->answer);
@@ -238,7 +239,9 @@ int main(int argc, char **argv)
     G_percent(1, 1, 1);
 
     /* Write arcs to new map */
-    Vect_open_new(&Out, output->answer, Vect_is_3d(&Map));
+    if (Vect_open_new(&Out, output->answer, Vect_is_3d(&Map)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output->answer);
+
     Vect_hist_command(&Out);
 
     nlines = Vect_get_num_lines(&Map);

+ 6 - 2
vector/v.net.iso/main.c

@@ -177,7 +177,9 @@ int main(int argc, char **argv)
 	geo = 0;
 
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, "");
+
+    if (Vect_open_old(&Map, map->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map->answer);
 
     /* Build graph */
     Vect_net_build_graph(&Map, type, afield, nfield, afcol->answer,
@@ -274,7 +276,9 @@ int main(int argc, char **argv)
     }
 
     /* Write arcs to new map */
-    Vect_open_new(&Out, output->answer, Vect_is_3d(&Map));
+    if (Vect_open_new(&Out, output->answer, Vect_is_3d(&Map)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output->answer);
+
     Vect_hist_command(&Out);
 
     G_message("Generating isolines...");

+ 2 - 1
vector/v.net.path/main.c

@@ -127,7 +127,8 @@ int main(int argc, char **argv)
 				 G_FATAL_EXIT);
 
     Vect_set_open_level(2);
-    Vect_open_old(&In, input_opt->answer, "");
+    if (Vect_open_old(&In, input_opt->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), input_opt->answer);
 
     if (1 > Vect_open_new(&Out, output_opt->answer, Vect_is_3d(&In))) {
 	Vect_close(&In);

+ 7 - 2
vector/v.net.salesman/main.c

@@ -219,7 +219,10 @@ int main(int argc, char **argv)
     Vect_check_input_output_name(map->answer, output->answer, G_FATAL_EXIT);
 
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, "");
+
+    if (Vect_open_old(&Map, map->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map->answer);
+
     nnodes = Vect_get_num_nodes(&Map);
     nlines = Vect_get_num_lines(&Map);
 
@@ -485,7 +488,9 @@ int main(int argc, char **argv)
     }
 
     /* Write arcs to new map */
-    Vect_open_new(&Out, output->answer, Vect_is_3d(&Map));
+    if (Vect_open_new(&Out, output->answer, Vect_is_3d(&Map)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output->answer);
+
     Vect_hist_command(&Out);
 
     G_verbose_message(_("Cycle with total cost %.3f"), cost);

+ 7 - 2
vector/v.net.steiner/main.c

@@ -425,7 +425,10 @@ int main(int argc, char **argv)
     Vect_check_input_output_name(map->answer, output->answer, G_FATAL_EXIT);
 
     Vect_set_open_level(2);
-    Vect_open_old(&Map, map->answer, "");
+
+    if (Vect_open_old(&Map, map->answer, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map->answer);
+
     nnodes = Vect_get_num_nodes(&Map);
     nlines = Vect_get_num_lines(&Map);
 
@@ -594,7 +597,9 @@ int main(int argc, char **argv)
 	fprintf(stdout, "\nSteiner tree costs = %f\n", cost);
 
     /* Write arcs to new map */
-    Vect_open_new(&Out, output->answer, Vect_is_3d(&Map));
+    if (Vect_open_new(&Out, output->answer, Vect_is_3d(&Map)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), output->answer);
+
     Vect_hist_command(&Out);
 
     fprintf(stdout, "\nSteiner tree:\n");

+ 3 - 1
vector/v.normal/main.c

@@ -107,7 +107,9 @@ int main(int argc, char **argv)
 
     /* Open input */
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, parm.input->answer, "", parm.layer->answer);
+    if (Vect_open_old2(&Map, parm.input->answer, "", parm.layer->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), parm.input->answer);
+
     field = Vect_get_field_number(&Map, parm.layer->answer);
     
     /* Read attributes */

+ 2 - 1
vector/v.out.dxf/main.c

@@ -75,7 +75,8 @@ int main(int argc, char *argv[])
     dxf_file = G_store(output->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old2(&In, input->answer, "", field->answer);
+    if (Vect_open_old2(&In, input->answer, "", field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), input->answer);
 
     dxf_open(dxf_file);		/* open output */
 

+ 4 - 1
vector/v.out.ogr/main.c

@@ -123,7 +123,10 @@ int main(int argc, char *argv[])
     if (!flags.new->answer) {
 	/* open input vector (topology required) */
 	Vect_set_open_level(2);
-	Vect_open_old2(&In, options.input->answer, "", options.field->answer);
+	if (Vect_open_old2(&In, options.input->answer, "",
+				options.field->answer) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"),
+			    options.input->answer);
 
 	if (strcmp(options.type->answer, "auto") == 0) {
 	    G_debug(2, "Automatic type determination.");

+ 2 - 1
vector/v.out.pov/main.c

@@ -93,7 +93,8 @@ int main(int argc, char *argv[])
 
     /* open input vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&In, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
     
     field = Vect_get_field_number(&In, field_opt->answer);
     

+ 2 - 1
vector/v.out.svg/main.c

@@ -135,7 +135,8 @@ int main(int argc, char *argv[])
 
     /* open input vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&In, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
 
     /* parse field number */
     field = Vect_get_field_number(&In, field_opt->answer);

+ 8 - 3
vector/v.overlay/main.c

@@ -174,7 +174,9 @@ int main(int argc, char *argv[])
 
     for (input = 0; input < 2; input++) {
         Vect_set_open_level(2);
-        Vect_open_old2(&(In[input]), in_opt[input]->answer, "", field_opt[input]->answer);
+        if (Vect_open_old2(&(In[input]), in_opt[input]->answer, "", field_opt[input]->answer) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"),
+			    in_opt[input]->answer);
 	field[input] = Vect_get_field_number(&(In[input]), field_opt[input]->answer);
     }
     if (type[0] == 0) { /* atype=auto */
@@ -204,12 +206,15 @@ int main(int argc, char *argv[])
     Cats = Vect_new_cats_struct();
 
     /* Open output */
-    Vect_open_new(&Out, out_opt->answer, WITHOUT_Z);
+    if (Vect_open_new(&Out, out_opt->answer, WITHOUT_Z) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
+
     Vect_set_map_name(&Out, "Output from v.overlay");
     Vect_set_person(&Out, G_whoami());
     Vect_hist_command(&Out);
     
-    Vect_open_tmp_new(&Tmp, NULL, WITHOUT_Z);
+    if (Vect_open_tmp_new(&Tmp, NULL, WITHOUT_Z) < 0)
+	G_fatal_error(_("Unable to create temporary vector map"));
 
     /* Create dblinks */
     if (ofield[0] > 0) {

+ 6 - 2
vector/v.parallel/main.c

@@ -142,10 +142,14 @@ int main(int argc, char *argv[])
 	side = 0;
 
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", layer_opt->answer);
+
+    if (Vect_open_old2(&In, in_opt->answer, "", layer_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
     layer = Vect_get_field_number(&In, layer_opt->answer);
 
-    Vect_open_new(&Out, out_opt->answer, 0);
+    if (Vect_open_new(&Out, out_opt->answer, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
     
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);

+ 16 - 7
vector/v.patch/main.c

@@ -110,7 +110,8 @@ int main(int argc, char *argv[])
 	Vect_check_input_output_name(in_name, new->answer, G_FATAL_EXIT);
 
 	Vect_set_open_level(2);
-	Vect_open_old_head(&InMap, in_name, "");
+	if (Vect_open_old_head(&InMap, in_name, "") < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), in_name);
 
 	if (out_is_3d != WITH_Z && Vect_is_3d(&InMap))
 	    out_is_3d = WITH_Z;
@@ -123,7 +124,8 @@ int main(int argc, char *argv[])
     if (do_table) {
 	if (append->answer) {
 	    Vect_set_open_level(1);
-	    Vect_open_old_head(&OutMap, out_name, G_mapset());
+	    if (Vect_open_old_head(&OutMap, out_name, G_mapset()) < 0)
+		G_fatal_error(_("Unable to open vector map <%s>"), out_name);
 
 	    fi_out = Vect_get_field(&OutMap, 1);
 	    if (fi_out) {
@@ -151,7 +153,8 @@ int main(int argc, char *argv[])
 	while (old->answers[i]) {
 	    in_name = old->answers[i];
 	    Vect_set_open_level(1);
-	    Vect_open_old_head(&InMap, in_name, "");
+	    if (Vect_open_old_head(&InMap, in_name, "") < 0)
+		G_fatal_error(_("Unable to open vector map <%s>"), in_name);
 
 	    fi_in = Vect_get_field(&InMap, 1);
 	    table_in = NULL;
@@ -245,18 +248,23 @@ int main(int argc, char *argv[])
     if (append->answer) {
 	if (no_topo->answer)
 	    Vect_set_open_level(1);
-	Vect_open_update(&OutMap, out_name, G_mapset());
+
+	if (Vect_open_update(&OutMap, out_name, G_mapset()) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), out_name);
+
 	if (out_is_3d == WITH_Z && !Vect_is_3d(&OutMap)) {
 	    G_warning(_("The output map is not 3D"));
 	}
 	maxcat = max_cat(&OutMap, 1);
     }
     else {
-	Vect_open_new(&OutMap, out_name, out_is_3d);
+	if (Vect_open_new(&OutMap, out_name, out_is_3d) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"), out_name);
     }
 
     if (bbox_name) {
-	Vect_open_new(&BBoxMap, bbox_name, out_is_3d);	/* TODO 3D */
+	if (Vect_open_new(&BBoxMap, bbox_name, out_is_3d) < 0)	/* TODO 3D */
+	    G_fatal_error(_("Unable to create vector map <%s>"), bbox_name);
 	Vect_hist_command(&BBoxMap);
     }
 
@@ -316,7 +324,8 @@ int main(int argc, char *argv[])
 	    Vect_set_open_level(2);	/* needed for Vect_map_box() */
 	else
 	    Vect_set_open_level(1);
-	Vect_open_old(&InMap, in_name, "");
+	if (Vect_open_old(&InMap, in_name, "") < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), in_name);
 
 	/*first time around, copy first in head to out head */
 	if (i == 1)

+ 6 - 3
vector/v.perturb/main.c

@@ -141,12 +141,14 @@ int main(int argc, char **argv)
 
     /* Open input */
     Vect_set_open_level(2);
-    Vect_open_old_head2(&In, parm.in->answer, "", parm.field->answer);
+    if (Vect_open_old_head2(&In, parm.in->answer, "", parm.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), parm.in->answer);
     
     field = Vect_get_field_number(&In, parm.field->answer);
     
     /* Open output */
-    Vect_open_new(&Out, parm.out->answer, WITHOUT_Z);	/* TODO add z support ? */
+    if (Vect_open_new(&Out, parm.out->answer, WITHOUT_Z) < 0)	/* TODO add z support ? */
+	G_fatal_error(_("Unable to create vector map <%s>"), parm.out->answer);
 
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
@@ -164,7 +166,8 @@ int main(int argc, char **argv)
     /* Close input, re-open on level 1 */
     Vect_close(&In);
     Vect_set_open_level(1);
-    Vect_open_old2(&In, parm.in->answer, "", parm.field->answer);
+    if (Vect_open_old2(&In, parm.in->answer, "", parm.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), parm.in->answer);
 
     i = 0;
     line = 0;

+ 6 - 2
vector/v.proj/main.c

@@ -220,7 +220,8 @@ int main(int argc, char *argv[])
 	Vect_set_open_level(1);
 	G_debug(1, "Open old: location: %s mapset : %s", G_location_path(),
 		G_mapset());
-	Vect_open_old(&Map, map_name, mapset);
+	if (Vect_open_old(&Map, map_name, mapset) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"), map_name);
     }
     else if (stat < 0)
     {				/* allow 0 (i.e. denied permission) */
@@ -360,7 +361,10 @@ int main(int argc, char *argv[])
 
     G_debug(1, "Open new: location: %s mapset : %s", G_location_path(),
 	    G_mapset());
-    Vect_open_new(&Out_Map, omap_name, Vect_is_3d(&Map));
+
+    if (Vect_open_new(&Out_Map, omap_name, Vect_is_3d(&Map)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), omap_name);
+
     Vect_set_error_handler_io(NULL, &Out_Map); /* register standard i/o error handler */
     
     Vect_copy_head_data(&Map, &Out_Map);

+ 6 - 2
vector/v.qcount/main.c

@@ -96,7 +96,8 @@ int main(int argc, char **argv)
 
     /* Open input */
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, parm.input->answer, "", parm.field->answer);
+    if (Vect_open_old2(&Map, parm.input->answer, "", parm.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), parm.input->answer);
 
     /* Get the quadrats */
     G_message(_("Finding quadrats..."));
@@ -121,7 +122,10 @@ int main(int argc, char **argv)
 	Points = Vect_new_line_struct();
 	Cats = Vect_new_cats_struct();
 
-	Vect_open_new(&Out, parm.output->answer, 0);
+	if (Vect_open_new(&Out, parm.output->answer, 0) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"),
+			    parm.output->answer);
+
 	Vect_hist_command(&Out);
 
 	for (i = 0; i < nquads; i++) {

+ 5 - 2
vector/v.reclass/main.c

@@ -109,10 +109,13 @@ int main(int argc, char *argv[])
 				 G_FATAL_EXIT);
 
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&In, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
     field = Vect_get_field_number(&In, field_opt->answer);
 
-    Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
+
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);

+ 6 - 2
vector/v.rectify/main.c

@@ -144,7 +144,8 @@ int main(int argc, char *argv[])
 		      MAXORDER);
 
     Vect_set_open_level(1);
-    Vect_open_old2(&In, in_opt->answer, "", "");
+    if (Vect_open_old2(&In, in_opt->answer, "", "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
     
     use3d = (Vect_is_3d(&In) &&
              (flag_use3d->answer || ortho->answer));
@@ -221,7 +222,10 @@ int main(int argc, char *argv[])
 	G_debug(1, "Overwriting OK");
 
     select_target_env();
-    Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
+
+    if (Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
+
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);

+ 8 - 2
vector/v.sample/main.c

@@ -119,7 +119,10 @@ int main(int argc, char **argv)
 
     /* Open input */
     Vect_set_open_level(2);
-    Vect_open_old2(&In, parm.input->answer, "", parm.field->answer);
+
+    if (Vect_open_old2(&In, parm.input->answer, "", parm.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), parm.input->answer);
+
     field = Vect_get_field_number(&In, parm.field->answer);
     
     fdrast = Rast_open_old(parm.rast->answer, "");
@@ -154,7 +157,10 @@ int main(int argc, char **argv)
     db_close_database_shutdown_driver(Driver);
 
     /* Open output */
-    Vect_open_new(&Out, parm.output->answer, 0);
+    if (Vect_open_new(&Out, parm.output->answer, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"),
+			parm.output->answer);
+
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 

+ 7 - 2
vector/v.segment/main.c

@@ -99,11 +99,16 @@ int main(int argc, char **argv)
 
     /* Open input lines */
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", lfield_opt->answer);
+
+    if (Vect_open_old2(&In, in_opt->answer, "", lfield_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
     lfield = Vect_get_field_number(&In, lfield_opt->answer);
 
     /* Open output segments */
-    Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
+
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 

+ 10 - 2
vector/v.select/main.c

@@ -101,7 +101,12 @@ int main(int argc, char *argv[])
 				     G_FATAL_EXIT);
 
 	Vect_set_open_level(2);
-	Vect_open_old2(&(In[iopt]), parm.input[iopt]->answer, "", parm.field[iopt]->answer);
+
+	if (Vect_open_old2(&(In[iopt]), parm.input[iopt]->answer, "",
+				parm.field[iopt]->answer) < 0)
+	    G_fatal_error(_("Unable to open vector map <%s>"),
+			    parm.input[iopt]->answer);
+
 	ifield[iopt] = Vect_get_field_number(&(In[iopt]), parm.field[iopt]->answer);
     }
 
@@ -112,7 +117,10 @@ int main(int argc, char *argv[])
     IFi = Vect_get_field(&(In[0]), ifield[0]);
 
     /* Open output */
-    Vect_open_new(&Out, parm.output->answer, Vect_is_3d(&(In[0])));
+    if (Vect_open_new(&Out, parm.output->answer, Vect_is_3d(&(In[0]))) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"),
+			parm.output->answer);
+
     Vect_set_map_name(&Out, _("Output from v.select"));
     Vect_set_person(&Out, G_whoami());
     Vect_copy_head_data(&(In[0]), &Out);

+ 6 - 2
vector/v.split/main.c

@@ -156,10 +156,14 @@ int main(int argc, char *argv[])
     nosplit = nosplit_flag->answer;
     
     Vect_set_open_level(2);
-    Vect_open_old2(&In, in_opt->answer, "", layer_opt->answer);
+
+    if (Vect_open_old2(&In, in_opt->answer, "", layer_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
     layer = Vect_get_field_number(&In, layer_opt->answer);
     
-    Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);
     
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);

+ 3 - 1
vector/v.surf.idw/read_sites.c

@@ -25,7 +25,9 @@ void read_sites(const char *name, const char *field_name, const char *col, int n
     struct line_cats *Cats;
 
     Vect_set_open_level(1);	/* without topology */
-    Vect_open_old2(&Map, name, "", field_name);
+    if (Vect_open_old2(&Map, name, "", field_name) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), name);
+
     field = Vect_get_field_number(&Map, field_name);
     with_z = col == NULL && Vect_is_3d(&Map); /* read z-coordinates
                                                  only when column is

+ 7 - 4
vector/v.surf.rst/main.c

@@ -565,10 +565,13 @@ int main(int argc, char *argv[])
 	Cats2 = Vect_new_cats_struct();
 	db_init_string(&sql2);
 
-	if (devi != NULL)
-	    Vect_open_new(&Map2, devi, 1);
-	else
-	    Vect_open_new(&Map2, cvdev, 1);
+	if (devi != NULL) {
+	    if (Vect_open_new(&Map2, devi, 1) < 0)
+		G_fatal_error(_("Unable to create vector map <%s>"), devi);
+	} else {
+	    if (Vect_open_new(&Map2, cvdev, 1) < 0)
+		G_fatal_error(_("Unable to create vector map <%s>"), cvdev);
+	}
 	Vect_hist_command(&Map2);
 	ff = Vect_default_field_info(&Map2, 1, NULL, GV_1TABLE);
 	Vect_map_add_dblink(&Map2, 1, NULL, ff->table, GV_KEY_COLUMN, ff->database,

+ 2 - 1
vector/v.to.db/main.c

@@ -45,7 +45,8 @@ int main(int argc, char *argv[])
 
     /* open map */
     Vect_set_open_level(2);
-    Vect_open_old(&Map, options.name, "");
+    if (Vect_open_old(&Map, options.name, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), options.name);
 
     Fi = Vect_get_field(&Map, options.field);
 

+ 8 - 2
vector/v.to.points/main.c

@@ -116,13 +116,19 @@ int main(int argc, char **argv)
 
     /* Open input lines */
     Vect_set_open_level(2);
-    Vect_open_old2(&In, opt.input->answer, "", opt.lfield->answer);
+
+    if (Vect_open_old2(&In, opt.input->answer, "", opt.lfield->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.input->answer);
+
     Vect_set_error_handler_io(&In, &Out);
     
     field = Vect_get_field_number(&In, opt.lfield->answer);
     
     /* Open output segments */
-    Vect_open_new(&Out, opt.output->answer, Vect_is_3d(&In));
+    if (Vect_open_new(&Out, opt.output->answer, Vect_is_3d(&In)) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"),
+			opt.output->answer);
+
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);

+ 7 - 3
vector/v.to.rast/support.c

@@ -119,7 +119,8 @@ int update_dbcolors(const char *rast_name, const char *vector_map, int field,
     Rast_init_colors(&colors);
 
     /* open vector map and database driver */
-    Vect_open_old(&Map, vector_map, "");
+    if (Vect_open_old(&Map, vector_map, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), vector_map);
 
     db_CatValArray_init(&cvarr);
     if ((Fi = Vect_get_field(&Map, field)) == NULL)
@@ -277,7 +278,8 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 
 	    /* open vector map and database driver */
 	    Vect_set_open_level(1);
-	    Vect_open_old(&Map, vector_map, G_find_vector2(vector_map, ""));
+	    if (Vect_open_old(&Map, vector_map, G_find_vector2(vector_map, "")) < 0)
+		G_fatal_error(_("Unable to open vector map <%s>"), vector_map);
 
 	    db_CatValArray_init(&cvarr);
 	    if (!(Fi = Vect_get_field(&Map, field)))
@@ -428,7 +430,9 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 
 		/* open vector map and database driver */
 		Vect_set_open_level(1);
-		Vect_open_old(&Map, vector_map, G_find_vector2(vector_map, ""));
+		if (Vect_open_old(&Map, vector_map, G_find_vector2(vector_map, "")) < 0)
+		    G_fatal_error(_("Unable to open vector map <%s>"),
+				    vector_map);
 
 		db_CatValArray_init(&cvarr);
 		if (!(Fi = Vect_get_field(&Map, field)))

+ 3 - 1
vector/v.to.rast/vect2rast.c

@@ -35,7 +35,9 @@ int vect_to_rast(const char *vector_map, const char *raster_map, const char *fie
 
     G_verbose_message(_("Loading data..."));
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, vector_map, "", field_name);
+    if (Vect_open_old2(&Map, vector_map, "", field_name) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), vector_map);
+
     field = Vect_get_field_number(&Map, field_name);
 
     if (field > 0)

+ 3 - 1
vector/v.to.rast3/main.c

@@ -69,7 +69,9 @@ int main(int argc, char *argv[])
     Rast3d_get_window(&region);
 
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, in_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&Map, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
     field = Vect_get_field_number(&Map, field_opt->answer);
 
     db_CatValArray_init(&cvarr);

+ 4 - 2
vector/v.transform/main.c

@@ -174,7 +174,8 @@ int main(int argc, char *argv[])
     Vect_check_input_output_name(vold->answer, vnew->answer, G_FATAL_EXIT);
 
     /* open input vector */
-    Vect_open_old2(&Old, vold->answer, "", field_opt->answer);
+    if (Vect_open_old2(&Old, vold->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), vold->answer);
 
     field = Vect_get_field_number(&Old, field_opt->answer);
     if (field < 1 && columns->answer) {
@@ -241,7 +242,8 @@ int main(int argc, char *argv[])
 	out3d = WITH_Z;
 
     /* open output vector */
-    Vect_open_new(&New, vnew->answer, out3d);
+    if (Vect_open_new(&New, vnew->answer, out3d) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), vnew->answer);
 
     /* copy and set header */
     Vect_copy_head_data(&Old, &New);

+ 3 - 1
vector/v.type/main.c

@@ -124,7 +124,9 @@ int main(int argc, char *argv[])
 
     /* open input vector */
     Vect_set_open_level(1);
-    Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&In, in_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
     field = Vect_get_field_number(&In, field_opt->answer);
     
     if (0 > Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In))) {

+ 3 - 1
vector/v.univar/main.c

@@ -151,7 +151,9 @@ int main(int argc, char *argv[])
 
     /* open input vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, map_opt->answer, "", field_opt->answer);
+    if (Vect_open_old2(&Map, map_opt->answer, "", field_opt->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), map_opt->answer);
+
     ofield = Vect_get_field_number(&Map, field_opt->answer);
     
     if ((otype & GV_POINT) && Vect_get_num_primitives(&Map, GV_POINT) == 0) {

+ 4 - 2
vector/v.vect.stats/main.c

@@ -253,7 +253,8 @@ int main(int argc, char *argv[])
 	G_fatal_error(_("Vector map <%s> not found"), point_opt->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&PIn, point_opt->answer, mapset);
+    if (Vect_open_old(&PIn, point_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), point_opt->answer);
 
     /* Open areas vector */
     if ((mapset = G_find_vector2(area_opt->answer, "")) == NULL)
@@ -263,7 +264,8 @@ int main(int argc, char *argv[])
 		      area_opt->answer);
 
     Vect_set_open_level(2);
-    Vect_open_old(&AIn, area_opt->answer, mapset);
+    if (Vect_open_old(&AIn, area_opt->answer, mapset) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), area_opt->answer);
 
     method = -1;
     use_catno = 0;

+ 9 - 5
vector/v.vol.rst/main.c

@@ -559,7 +559,8 @@ int main(int argc, char *argv[])
     }
 
     Vect_set_open_level(1);
-    Vect_open_old(&In, input, "");
+    if (Vect_open_old(&In, input, "") < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), input);
 
     if (!Vect_is_3d(&In))
 	G_warning(_("Vector is not 3D"));
@@ -577,10 +578,13 @@ int main(int argc, char *argv[])
 	Cats = Vect_new_cats_struct();
 	db_init_string(&sql);
 
-	if (devi != NULL)
-	    Vect_open_new(&Map, devi, 1);
-	else
-	    Vect_open_new(&Map, cvdev, 1);
+	if (devi != NULL) {
+	    if (Vect_open_new(&Map, devi, 1) < 0)
+		G_fatal_error(_("Unable to create vector map <%s>"), devi);
+	} else {
+	    if (Vect_open_new(&Map, cvdev, 1) < 0)
+		G_fatal_error(_("Unable to create vector map <%s>"), cvdev);
+	}
 	Vect_hist_command(&Map);
 	f = Vect_default_field_info(&Map, 1, NULL, GV_1TABLE);
 	Vect_map_add_dblink(&Map, 1, NULL, f->table, GV_KEY_COLUMN, f->database,

+ 4 - 2
vector/v.voronoi/main.c

@@ -191,7 +191,8 @@ int main(int argc, char **argv)
 
     /* open files */
     Vect_set_open_level(2);
-    Vect_open_old2(&In, opt.in->answer, "", opt.field->answer);
+    if (Vect_open_old2(&In, opt.in->answer, "", opt.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.in->answer);
 
     Field = Vect_get_field_number(&In, opt.field->answer);
     
@@ -209,7 +210,8 @@ int main(int argc, char **argv)
     else
 	readsites();
 
-    Vect_open_new(&Out, opt.out->answer, 0);
+    if (Vect_open_new(&Out, opt.out->answer, 0) < 0)
+	G_fatal_error(_("Unable to create vector map <%s>"), opt.out->answer);
 
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);

+ 3 - 2
vector/v.what.rast/main.c

@@ -124,9 +124,10 @@ int main(int argc, char *argv[])
 
     /* Open vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, opt.vect->answer,
+    if (Vect_open_old2(&Map, opt.vect->answer,
 		   print_flag->answer ? "" : G_mapset(),
-		   opt.field->answer);
+		   opt.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.vect->answer);
 
     field = Vect_get_field_number(&Map, opt.field->answer);
 

+ 2 - 1
vector/v.what.rast3/main.c

@@ -109,7 +109,8 @@ int main(int argc, char *argv[])
 
     /* Open vector */
     Vect_set_open_level(2);
-    Vect_open_old2(&Map, opt.vect->answer, "", opt.field->answer);
+    if (Vect_open_old2(&Map, opt.vect->answer, "", opt.field->answer) < 0)
+	G_fatal_error(_("Unable to open vector map <%s>"), opt.vect->answer);
 
     field = Vect_get_field_number(&Map, opt.field->answer);