[GRASS-dev] [bug #5197] (grass) v.distance: segfault when 'from' vector doesn't exist

Hamish hamish_nospam at yahoo.com
Mon Oct 9 23:58:34 EDT 2006

Request Tracker wrote:
> this bug's URL: http://intevation.de/rt/webrt?serial_num=5197
> ---------------------------------------------------------------------
> Subject: v.distance: segfault when 'from' vector doesn't exist
> $ v.distance from=dummy1 to=dummy2 upload=cat col=nic
> Segmentation fault

fixed in CVS HEAD & 6.2.

it was checking the vector map, but then didn't check to see what the
result of that test was. The test returns the mapset name on success.

> Interestingly, with '-p' it will behave as supposed to:
> $ v.distance -p from=dummy1 to=dummy2 upload=cat col=nic
> ERROR: Cannot find vector dummy1@

that's because it broke on this strcmp() when "mapset" was NULL:

if ( !print_flag->answer && strcmp(mapset,G_mapset()) != 0 )
   G_fatal_error(_("Vector 'from' is not in user mapset and cannot be updated"));

> BTW: why 'dummy1@' instead of 'dummy1 at mapset_name'?

map wasn't found so mapset was NULL, and NULL at the end of a string
is just the end of the string.

> I noticed the many (all?) modules have been recently doing that.

if you can still find them, please provide specifics.

my question, and maybe the bigger bug, is why G_parser() didn't catch
        /*vector maps*/    
        case G_OPT_V_INPUT:
            Opt->key          = "input";
            Opt->type         = TYPE_STRING;
            Opt->key_desc     = "name";
            Opt->required     = YES;
            Opt->gisprompt    = "old,vector,vector";
            Opt->description  = _("Name of input vector map");

I thought the "old" in gisprompt meant that it was tested. Or is that
just true for "new"?


More information about the grass-dev mailing list