[GRASS5] CygWIN: MinGW compilation of R/GRASS interface

Glynn Clements glynn.clements at virgin.net
Tue Feb 18 10:43:42 EST 2003

Roger Bivand wrote:

> > > I've submitted GRASS_0.2-2 to CRAN, thanks for your help. One problem that 
> > > I hit is that strlen() in G_store() usually crashes (MinGW and gcc RH 
> > > 2.96) when passed a NULL string - a test might be an idea anyway in 
> > > libes/gis/store.c.
> > 
> > If you know of any specific cases where NULL might be passed to
> > G_store(), please report them, as they may indicate that a "not-NULL"
> > check should be added to the caller.
> > 
> In my R_G_init.c, in function R_G_get_gisrc_file()
>       gisrc = G_store(G__get_gisrc_file());

For now, I suggest:

	gisrc = G__get_gisrc_file()
	if (gisrc) gisrc = G_store(gisrc);

If this was likely to be common, it wouldn't hurt to add:

	if (!s) return s;

to the beginning of G_store().

> in both cases. Maybe it doesn't happen anywhere else, but I didn't expect 
> strlen() to be vulnerable - I thought it would give some sensible return 
> value (-1 is logical) when handed a NULL string.

strcpy() fails similarly, as do most of the string.h functions. BTW,
strdup() (which does the same thing as G_store()) also segfaults when
passed a NULL pointer.

Glynn Clements <glynn.clements at virgin.net>

More information about the grass-dev mailing list