[GRASS-SVN] r63932 - grass/branches/releasebranch_7_0/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 2 03:53:30 PST 2015


Author: martinl
Date: 2015-01-02 03:53:30 -0800 (Fri, 02 Jan 2015)
New Revision: 63932

Modified:
   grass/branches/releasebranch_7_0/lib/vector/Vlib/map.c
Log:
vlib: continue in deleting vector map even linked table not found or unable to delete
Added missing checks for Vect_open_* return value to avoid potential segmentation fault
      (merge r59568 and r60054 from trunk)


Modified: grass/branches/releasebranch_7_0/lib/vector/Vlib/map.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/vector/Vlib/map.c	2015-01-02 11:24:02 UTC (rev 63931)
+++ grass/branches/releasebranch_7_0/lib/vector/Vlib/map.c	2015-01-02 11:53:30 UTC (rev 63932)
@@ -155,7 +155,8 @@
 
     /* 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 @@
 
     /* 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 @@
 
     /* 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);
@@ -440,8 +443,11 @@
                 if (Fi == NULL) {
                     G_warning(_("Database connection not defined for layer %d"),
                               Map.dblnk->field[i].number);
-                    Vect_close(&Map);
-                    return -1;
+                    /* 
+                       Vect_close(&Map);
+                       return -1;
+                    */
+                    continue;
                 }
                 G_debug(3, "Delete drv:db:table '%s:%s:%s'", Fi->driver,
                         Fi->database, Fi->table);
@@ -450,8 +456,11 @@
                 if (ret == -1) {
                     G_warning(_("Unable to find table <%s> linked to vector map <%s>"),
                               Fi->table, map);
-                    Vect_close(&Map);
-                    return -1;
+                    /* 
+                       Vect_close(&Map);
+                       return -1;
+                    */
+                    continue;
                 }
 
                 if (ret == 1) {
@@ -460,8 +469,11 @@
                     if (ret == DB_FAILED) {
                         G_warning(_("Unable to delete table <%s>"),
                                   Fi->table);
-                        Vect_close(&Map);
-                        return -1;
+                        /*
+                          Vect_close(&Map);
+                          return -1;
+                        */
+                        continue;
                     }
                 }
                 else {



More information about the grass-commit mailing list