Hi,
I found a segfault using ps.map with a malformed SQL statement:
#spearfish
ps.map out=test.ps << EOF
vpoints bugsites
# where str1 = 'o12' OR str1 = 'o13'
where str1 = 'o12' OR 'o13'
end
end
EOF
is this patch the correct approach?
Hamish
Index: lib/vector/Vlib/array.c
RCS file: /home/grass/grassrepository/grass6/lib/vector/Vlib/array.c,v
retrieving revision 1.5
diff -u -r1.5 array.c
--- lib/vector/Vlib/array.c 9 Feb 2006 03:08:58 -0000 1.5
+++ lib/vector/Vlib/array.c 26 Sep 2007 03:38:04 -0000
@@ -242,10 +242,15 @@
G_warning ( "Cannot open database" );
return -1;
}
-
+
ncats = db_select_int( driver, Fi->table, Fi->key, where, &cats);
db_close_database_shutdown_driver ( driver );
+
+ if(ncats == -1) {
+ G_warning("Error selecting records from database");
+ return -1;
+ }
if ( type & GV_AREA ) { /* Areas */
n = Vect_get_num_areas (Map);
Index: ps/ps.map/ps_vpoints.c
RCS file: /home/grass/grassrepository/grass6/ps/ps.map/ps_vpoints.c,v
retrieving revision 1.10
diff -u -r1.10 ps_vpoints.c
--- ps/ps.map/ps_vpoints.c 27 Aug 2007 07:02:39 -0000 1.10
+++ ps/ps.map/ps_vpoints.c 26 Sep 2007 03:38:03 -0000
@@ -60,6 +60,8 @@
vector.layer[vec].where, vector.layer
[vec].ltype, 1, Varray ); }
G_debug ( 3, "%d items selected for vector %d", ret, vec );
+ if(ret == -1)
+ G_fatal_error(_("Reading vector attributes"));
}
/* allocate memory for coordinates */