Inspired by Hamish's bug #5352 , I found out that this one segfaults:
v.db.select map=test where="MAPS_COVER='built up'"
while this one one works OK:
v.db.select map=test where="MAPS_COVER = 'built up'"
This is strange as both notations are allowed according to examples in GRASS
manual, and as the former one segfaults only on my 2 32bit machines, while it
doesn't on Brad's and Markus's 64bit.
???
Maciek
-------------------------------------------- Managed by Request Tracker
H_B
December 1, 2006, 2:39am
2
G63> v.db.select archsites where="CAT = 1" col=cat
cat
1
G63> v.db.select archsites where="CAT=1" col=cat
cat
11
==> that is very bad, it reports the attribute of the wrong cat !
found it.
v.db.select/main.c:
if (where_opt->answer) {
char *buf = NULL;
- buf = G_malloc ((strlen(where_opt->answer) + 7));
+ buf = G_malloc ((strlen(where_opt->answer) + 8));
sprintf (buf, " WHERE %s", where_opt->answer);
db_append_string ( &sql, buf );
G_free (buf);
}
strlen() returns the length of the string without the null terminator.
So the *buf string was allocated one smaller than it needed to be.
fixed in CVS & 6.2 branch.
Hamish